From 5343d38afa12dde0c66e2be6883e4b0ee88c01a5 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 27 Nov 2019 20:45:15 +0200 Subject: [PATCH 01/23] ISAICP-5599: Initial attempt to setup travis. --- .travis.yml | 74 +++++++++++++++++++++ tests/travis-ci/fixtures/composer.json.dist | 53 +++++++++++++++ tests/travis-ci/fixtures/connection.txt | 8 +++ tests/travis-ci/fixtures/phpunit.xml.dist | 33 +++++++++ tests/travis-ci/scripts/run_tests | 18 +++++ 5 files changed, 186 insertions(+) create mode 100644 .travis.yml create mode 100644 tests/travis-ci/fixtures/composer.json.dist create mode 100644 tests/travis-ci/fixtures/connection.txt create mode 100644 tests/travis-ci/fixtures/phpunit.xml.dist create mode 100755 tests/travis-ci/scripts/run_tests diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2f31e33 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,74 @@ +language: php + +php: + - '7.1' + - '7.2' + - '7.3' + +sudo: required + +services: + - docker + +mysql: + database: sparql_entity_storage_test + username: root + encoding: utf8 + +env: + global: + - SITE_DIR="$HOME/build/testing_site" + matrix: + - TEST=PHP_CodeSniffer + - TEST=8.6.x + - TEST=8.7.x + - TEST=8.8.x + +matrix: + fast_finish: true + exclude: + - php: '7.2' + env: TEST=PHP_CodeSniffer + - php: '7.3' + env: TEST=PHP_CodeSniffer + +before_install: + - composer --verbose self-update + - mkdir -p ${SITE_DIR}/web/modules + - cd ${SITE_DIR} + + ### PHP_CodeSniffer only. + + # We only need the PHP Code Sniffer (and the Drupal coder). + - test ${TEST} == "PHP_CodeSniffer" && composer require drupal/coder || true + + ### PHPUnit only (till the end). + + # Deploy the codebase. + - test ${TEST} == "PHP_CodeSniffer" || cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/composer.json.dist ${SITE_DIR}/composer.json + - test ${TEST} == "PHP_CodeSniffer" || cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/phpunit.xml.dist ${SITE_DIR}/web/phpunit.xml + - test ${TEST} == "PHP_CodeSniffer" || perl -i -pe's/\$\{([^}]+)\}/$ENV{$1}/' composer.json + - test ${TEST} == "PHP_CodeSniffer" || composer require drupal/core:${TEST} --no-interaction + # Virtuoso setup. + - test ${TEST} == "PHP_CodeSniffer" || mkdir ${SITE_DIR}/virtuoso + - test ${TEST} == "PHP_CodeSniffer" || docker run --name virtuoso -p 8890:8890 -p 1111:1111 -e SPARQL_UPDATE=true -v ${SITE_DIR}/virtuoso:/data -d tenforce/virtuoso + # Create the MySQL database. + - test ${TEST} == "PHP_CodeSniffer" || mysql -e 'CREATE DATABASE sparql_entity_storage_test' + # Install Drupal. + - test ${TEST} == "PHP_CodeSniffer" || ./vendor/bin/drush site:install testing --yes --root=${SITE_DIR}/web --db-url=mysql://root:@127.0.0.1/sparql_entity_storage_test + # Add the SPARQL connection to settings.php. + - test ${TEST} == "PHP_CodeSniffer" || chmod 0775 ${SITE_DIR}/web/sites/default/settings.php + - test ${TEST} == "PHP_CodeSniffer" || cat ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/connection.txt >> ${SITE_DIR}/web/sites/default/settings.php + # Enable the 'sparql_entity_storage' module. + - test ${TEST} == "PHP_CodeSniffer" || ./vendor/bin/drush pm:enable sparql_entity_storage --yes --root=${SITE_DIR}/web + # Start the webserver for browser tests. + - cd ${SITE_DIR}/web + - test ${TEST} == "PHP_CodeSniffer" || nohup php -S localhost:8888 > /dev/null 2>&1 & + # Wait until the web server is responding. + - test ${TEST} == "PHP_CodeSniffer" || until curl -s localhost:8888; do true; done > /dev/null + - cd .. + +script: ${TRAVIS_BUILD_DIR}/tests/travis-ci/scripts/run_tests ${TEST} + +notifications: + email: false diff --git a/tests/travis-ci/fixtures/composer.json.dist b/tests/travis-ci/fixtures/composer.json.dist new file mode 100644 index 0000000..c7bf682 --- /dev/null +++ b/tests/travis-ci/fixtures/composer.json.dist @@ -0,0 +1,53 @@ +{ + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=7.1.0", + "composer/installers": "^1.5.0", + "cweagans/composer-patches": "^1.6.5", + "drupal-composer/drupal-scaffold": "dev-master", + "drupal/rdf_entity": "*", + "drush/drush": "~9", + "easyrdf/easyrdf": "0.10.0-alpha.1 as 0.9.2", + "ml/json-ld": "^1.0" + }, + "require-dev": { + "behat/mink-goutte-driver": "~1.2", + "mikey179/vfsstream": "~1.2", + "minimaxir/big-list-of-naughty-strings": "dev-master", + "phpunit/phpunit": "~6.0" + }, + "repositories": [ + { + "type": "path", + "url": "${TRAVIS_BUILD_DIR}" + }, + { + "type": "vcs", + "url": "https://github.com/ec-europa/sparql_entity_storage.git", + "no-api": true + }, + { + "type": "package", + "package": { + "name": "minimaxir/big-list-of-naughty-strings", + "version": "dev-master", + "dist": { + "url": "https://github.com/minimaxir/big-list-of-naughty-strings/archive/master.zip", + "type": "zip" + } + } + } + ], + "extra": { + "installer-paths": { + "web/core": ["type:drupal-core"], + "web/modules/{$name}": ["type:drupal-module"] + }, + "patches": { + "drupal/core": { + "Bundle label plural variants @see https://www.drupal.org/node/2765065": "https://www.drupal.org/files/issues/2018-06-11/2765065-93.patch" + } + } + } +} diff --git a/tests/travis-ci/fixtures/connection.txt b/tests/travis-ci/fixtures/connection.txt new file mode 100644 index 0000000..8ccd310 --- /dev/null +++ b/tests/travis-ci/fixtures/connection.txt @@ -0,0 +1,8 @@ + +$databases['sparql_default']['default'] = array ( + 'prefix' => '', + 'host' => '127.0.0.1', + 'port' => 8890, + 'namespace' => 'Drupal\\Driver\\Database\\sparql', + 'driver' => 'sparql', +); diff --git a/tests/travis-ci/fixtures/phpunit.xml.dist b/tests/travis-ci/fixtures/phpunit.xml.dist new file mode 100644 index 0000000..ab8c9b7 --- /dev/null +++ b/tests/travis-ci/fixtures/phpunit.xml.dist @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + ./modules/sparql_entity_storage + + + + + diff --git a/tests/travis-ci/scripts/run_tests b/tests/travis-ci/scripts/run_tests new file mode 100755 index 0000000..798fc2f --- /dev/null +++ b/tests/travis-ci/scripts/run_tests @@ -0,0 +1,18 @@ +#!/bin/bash + +case "$1" in + PHP_CodeSniffer) + cd ${SITE_DIR} + ./vendor/bin/phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer + ./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt --ignore='*.md' ${TRAVIS_BUILD_DIR} + exit $? + ;; + 8.*.x) + cd ${SITE_DIR}/web + ../vendor/bin/phpunit --testdox --verbose + exit $? + ;; + *) + echo "Unknown test '$1'" + exit 1 +esac From 765b2797ec94178831797c3d44401823a9bfb2c7 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 27 Nov 2019 21:05:52 +0200 Subject: [PATCH 02/23] ISAICP-5599: Remove rdf dependency. --- tests/travis-ci/fixtures/composer.json.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/travis-ci/fixtures/composer.json.dist b/tests/travis-ci/fixtures/composer.json.dist index c7bf682..2274ffe 100644 --- a/tests/travis-ci/fixtures/composer.json.dist +++ b/tests/travis-ci/fixtures/composer.json.dist @@ -6,7 +6,6 @@ "composer/installers": "^1.5.0", "cweagans/composer-patches": "^1.6.5", "drupal-composer/drupal-scaffold": "dev-master", - "drupal/rdf_entity": "*", "drush/drush": "~9", "easyrdf/easyrdf": "0.10.0-alpha.1 as 0.9.2", "ml/json-ld": "^1.0" From 2a03fb94d76a3658f7174086377e31ba085680de Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 27 Nov 2019 21:06:33 +0200 Subject: [PATCH 03/23] ISAICP-5599: Fix codesniffs. --- driver/sparql/Connection.php | 2 +- src/DataCollector/SparqlDataCollector.php | 10 ++++++++++ tests/src/Kernel/EntityCreationTest.php | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/driver/sparql/Connection.php b/driver/sparql/Connection.php index 0f51389..bce56ed 100644 --- a/driver/sparql/Connection.php +++ b/driver/sparql/Connection.php @@ -123,7 +123,7 @@ public function constructQuery(string $query, array $args = [], array $options = * @throws \InvalidArgumentException * If $args value is passed but arguments replacement is not yet * supported. To be removed in #55. - * @throws SparqlQueryException + * @throws \Drupal\sparql_entity_storage\Exception\SparqlQueryException * Exception during query execution, e.g. timeout. * * @see https://github.com/ec-europa/sparql_entity_storage/issues/1 diff --git a/src/DataCollector/SparqlDataCollector.php b/src/DataCollector/SparqlDataCollector.php index ff3ef26..3521990 100644 --- a/src/DataCollector/SparqlDataCollector.php +++ b/src/DataCollector/SparqlDataCollector.php @@ -19,8 +19,18 @@ class SparqlDataCollector extends DataCollector implements DrupalDataCollectorIn use StringTranslationTrait, DrupalDataCollectorTrait; + /** + * The connection class. + * + * @var \Drupal\sparql_entity_storage\Database\Driver\sparql\ConnectionInterface + */ private $database; + /** + * The config factory service. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ private $configFactory; /** diff --git a/tests/src/Kernel/EntityCreationTest.php b/tests/src/Kernel/EntityCreationTest.php index 2655836..a895431 100644 --- a/tests/src/Kernel/EntityCreationTest.php +++ b/tests/src/Kernel/EntityCreationTest.php @@ -4,7 +4,6 @@ namespace Drupal\Tests\sparql_entity_storage\Kernel; -use Drupal\rdf_entity\RdfInterface; use Drupal\sparql_entity_storage\Entity\SparqlGraph; use Drupal\sparql_entity_storage\Exception\DuplicatedIdException; use Drupal\sparql_test\Entity\SparqlTest; From e52c1698696c35378dd598262117b42695d84efb Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 27 Nov 2019 21:21:37 +0200 Subject: [PATCH 04/23] ISICP-5599: Travis is moving to xenial. Services are explicitly required. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2f31e33..b4289fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ sudo: required services: - docker + - mysql mysql: database: sparql_entity_storage_test From 283a6d528f01db3fb8fe4e0538156368b30bf56e Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 27 Nov 2019 21:26:28 +0200 Subject: [PATCH 05/23] ISAICP-5599: You need to have the module, to enable the module. --- tests/travis-ci/fixtures/composer.json.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/travis-ci/fixtures/composer.json.dist b/tests/travis-ci/fixtures/composer.json.dist index 2274ffe..a9cc55c 100644 --- a/tests/travis-ci/fixtures/composer.json.dist +++ b/tests/travis-ci/fixtures/composer.json.dist @@ -6,6 +6,7 @@ "composer/installers": "^1.5.0", "cweagans/composer-patches": "^1.6.5", "drupal-composer/drupal-scaffold": "dev-master", + "drupal/sparql_entity_storage": "*", "drush/drush": "~9", "easyrdf/easyrdf": "0.10.0-alpha.1 as 0.9.2", "ml/json-ld": "^1.0" From e271cd285fb4dbf5a4a2136c61c8ae7e7e4a6f83 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 27 Nov 2019 21:36:51 +0200 Subject: [PATCH 06/23] ISAICP-5599: Provide a better name for the test method. --- tests/src/Kernel/SparqlGraphTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Kernel/SparqlGraphTest.php b/tests/src/Kernel/SparqlGraphTest.php index b0fd26e..4768c36 100644 --- a/tests/src/Kernel/SparqlGraphTest.php +++ b/tests/src/Kernel/SparqlGraphTest.php @@ -22,7 +22,7 @@ class SparqlGraphTest extends SparqlKernelTestBase { /** * Tests graphs. */ - public function test(): void { + public function testSparqlGraphs(): void { /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $manager */ $manager = $this->container->get('entity_type.manager'); /** @var \Drupal\sparql_entity_storage\SparqlEntityStorage $storage */ From 8cc0a0f3dc784f9de15f0644ba0f834cfa6f6b2b Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 27 Nov 2019 22:01:20 +0200 Subject: [PATCH 07/23] ISAICP-5599: rdf_entity is still used in tests.. --- tests/travis-ci/fixtures/composer.json.dist | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/travis-ci/fixtures/composer.json.dist b/tests/travis-ci/fixtures/composer.json.dist index a9cc55c..b153f9b 100644 --- a/tests/travis-ci/fixtures/composer.json.dist +++ b/tests/travis-ci/fixtures/composer.json.dist @@ -6,6 +6,7 @@ "composer/installers": "^1.5.0", "cweagans/composer-patches": "^1.6.5", "drupal-composer/drupal-scaffold": "dev-master", + "drupal/rdf_entity": "*", "drupal/sparql_entity_storage": "*", "drush/drush": "~9", "easyrdf/easyrdf": "0.10.0-alpha.1 as 0.9.2", @@ -22,6 +23,11 @@ "type": "path", "url": "${TRAVIS_BUILD_DIR}" }, + { + "type": "vcs", + "url": "https://github.com/ec-europa/rdf_entity.git", + "no-api": true + }, { "type": "vcs", "url": "https://github.com/ec-europa/sparql_entity_storage.git", From f431cb3d60030b6ef919b55ba47a3f089bbd6eb4 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Tue, 19 Jan 2021 18:54:13 +0200 Subject: [PATCH 08/23] ISAICP-5599: Copy the configuration from rdf_entity for consistency. --- .travis.yml | 66 +++++++------------- tests/travis-ci/fixtures/composer.json.dist | 41 +++++++------ tests/travis-ci/fixtures/connection.txt | 2 +- tests/travis-ci/fixtures/phpstan.neon.dist | 6 ++ tests/travis-ci/fixtures/phpunit.xml.dist | 18 ++---- tests/travis-ci/scripts/run_tests | 18 ------ tests/travis-ci/scripts/run_tests.sh | 67 +++++++++++++++++++++ 7 files changed, 125 insertions(+), 93 deletions(-) create mode 100644 tests/travis-ci/fixtures/phpstan.neon.dist delete mode 100755 tests/travis-ci/scripts/run_tests create mode 100644 tests/travis-ci/scripts/run_tests.sh diff --git a/.travis.yml b/.travis.yml index b4289fd..4613d16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,15 @@ language: php php: - - '7.1' - '7.2' - '7.3' + - '7.4' sudo: required services: - - docker - mysql + - docker mysql: database: sparql_entity_storage_test @@ -20,56 +20,36 @@ env: global: - SITE_DIR="$HOME/build/testing_site" matrix: - - TEST=PHP_CodeSniffer - - TEST=8.6.x - - TEST=8.7.x - - TEST=8.8.x + - TEST=PHPCodeSniffer + - TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 + - TEST=PHPUnit DRUPAL=~8.9.0 PHPUNIT=^7 + - TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 + - TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 + - TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 matrix: fast_finish: true exclude: - php: '7.2' - env: TEST=PHP_CodeSniffer + env: TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 + - php: '7.2' + env: TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 + - php: '7.2' + env: TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 + - php: '7.3' + env: TEST=PHPCodeSniffer - php: '7.3' - env: TEST=PHP_CodeSniffer + env: TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 + - php: '7.4' + env: TEST=PHPCodeSniffer + - php: '7.4' + env: TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 before_install: - - composer --verbose self-update - - mkdir -p ${SITE_DIR}/web/modules - - cd ${SITE_DIR} - - ### PHP_CodeSniffer only. - - # We only need the PHP Code Sniffer (and the Drupal coder). - - test ${TEST} == "PHP_CodeSniffer" && composer require drupal/coder || true - - ### PHPUnit only (till the end). - - # Deploy the codebase. - - test ${TEST} == "PHP_CodeSniffer" || cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/composer.json.dist ${SITE_DIR}/composer.json - - test ${TEST} == "PHP_CodeSniffer" || cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/phpunit.xml.dist ${SITE_DIR}/web/phpunit.xml - - test ${TEST} == "PHP_CodeSniffer" || perl -i -pe's/\$\{([^}]+)\}/$ENV{$1}/' composer.json - - test ${TEST} == "PHP_CodeSniffer" || composer require drupal/core:${TEST} --no-interaction - # Virtuoso setup. - - test ${TEST} == "PHP_CodeSniffer" || mkdir ${SITE_DIR}/virtuoso - - test ${TEST} == "PHP_CodeSniffer" || docker run --name virtuoso -p 8890:8890 -p 1111:1111 -e SPARQL_UPDATE=true -v ${SITE_DIR}/virtuoso:/data -d tenforce/virtuoso - # Create the MySQL database. - - test ${TEST} == "PHP_CodeSniffer" || mysql -e 'CREATE DATABASE sparql_entity_storage_test' - # Install Drupal. - - test ${TEST} == "PHP_CodeSniffer" || ./vendor/bin/drush site:install testing --yes --root=${SITE_DIR}/web --db-url=mysql://root:@127.0.0.1/sparql_entity_storage_test - # Add the SPARQL connection to settings.php. - - test ${TEST} == "PHP_CodeSniffer" || chmod 0775 ${SITE_DIR}/web/sites/default/settings.php - - test ${TEST} == "PHP_CodeSniffer" || cat ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/connection.txt >> ${SITE_DIR}/web/sites/default/settings.php - # Enable the 'sparql_entity_storage' module. - - test ${TEST} == "PHP_CodeSniffer" || ./vendor/bin/drush pm:enable sparql_entity_storage --yes --root=${SITE_DIR}/web - # Start the webserver for browser tests. - - cd ${SITE_DIR}/web - - test ${TEST} == "PHP_CodeSniffer" || nohup php -S localhost:8888 > /dev/null 2>&1 & - # Wait until the web server is responding. - - test ${TEST} == "PHP_CodeSniffer" || until curl -s localhost:8888; do true; done > /dev/null - - cd .. + # Remove this line to run with Xdebug enabled. + - phpenv config-rm xdebug.ini || true -script: ${TRAVIS_BUILD_DIR}/tests/travis-ci/scripts/run_tests ${TEST} +script: ${TRAVIS_BUILD_DIR}/tests/travis-ci/scripts/run_tests.sh notifications: email: false diff --git a/tests/travis-ci/fixtures/composer.json.dist b/tests/travis-ci/fixtures/composer.json.dist index b153f9b..0ae8785 100644 --- a/tests/travis-ci/fixtures/composer.json.dist +++ b/tests/travis-ci/fixtures/composer.json.dist @@ -1,38 +1,32 @@ { - "minimum-stability": "dev", - "prefer-stable": true, "require": { - "php": ">=7.1.0", "composer/installers": "^1.5.0", "cweagans/composer-patches": "^1.6.5", - "drupal-composer/drupal-scaffold": "dev-master", - "drupal/rdf_entity": "*", - "drupal/sparql_entity_storage": "*", - "drush/drush": "~9", - "easyrdf/easyrdf": "0.10.0-alpha.1 as 0.9.2", + "drupal/core": "${DRUPAL}", + "drupal/core-composer-scaffold": "*", + "drupal/pathauto": "*", + "drupal/token": "*", + "drush/drush": "~10", + "easyrdf/easyrdf": "1.0.0 as 0.9.2", "ml/json-ld": "^1.0" }, "require-dev": { "behat/mink-goutte-driver": "~1.2", "mikey179/vfsstream": "~1.2", "minimaxir/big-list-of-naughty-strings": "dev-master", - "phpunit/phpunit": "~6.0" + "mglaman/phpstan-drupal": "^0.12.6", + "phpspec/prophecy": "^1.7", + "phpstan/phpstan-deprecation-rules": "^0.12.5", + "phpunit/phpunit": "${PHPUNIT}", + "symfony/phpunit-bridge": "^5.1.4" }, + "minimum-stability": "dev", + "prefer-stable": true, "repositories": [ { "type": "path", "url": "${TRAVIS_BUILD_DIR}" }, - { - "type": "vcs", - "url": "https://github.com/ec-europa/rdf_entity.git", - "no-api": true - }, - { - "type": "vcs", - "url": "https://github.com/ec-europa/sparql_entity_storage.git", - "no-api": true - }, { "type": "package", "package": { @@ -43,6 +37,10 @@ "type": "zip" } } + }, + { + "type": "composer", + "url": "https://packages.drupal.org/8" } ], "extra": { @@ -50,6 +48,11 @@ "web/core": ["type:drupal-core"], "web/modules/{$name}": ["type:drupal-module"] }, + "drupal-scaffold": { + "locations": { + "web-root": "web/" + } + }, "patches": { "drupal/core": { "Bundle label plural variants @see https://www.drupal.org/node/2765065": "https://www.drupal.org/files/issues/2018-06-11/2765065-93.patch" diff --git a/tests/travis-ci/fixtures/connection.txt b/tests/travis-ci/fixtures/connection.txt index 8ccd310..cf7b96a 100644 --- a/tests/travis-ci/fixtures/connection.txt +++ b/tests/travis-ci/fixtures/connection.txt @@ -3,6 +3,6 @@ $databases['sparql_default']['default'] = array ( 'prefix' => '', 'host' => '127.0.0.1', 'port' => 8890, - 'namespace' => 'Drupal\\Driver\\Database\\sparql', + 'namespace' => 'Drupal\\sparql_entity_storage\\Driver\\Database\\sparql', 'driver' => 'sparql', ); diff --git a/tests/travis-ci/fixtures/phpstan.neon.dist b/tests/travis-ci/fixtures/phpstan.neon.dist new file mode 100644 index 0000000..f4ff428 --- /dev/null +++ b/tests/travis-ci/fixtures/phpstan.neon.dist @@ -0,0 +1,6 @@ +parameters: + customRulesetUsed: true + reportUnmatchedIgnoredErrors: false +includes: + - vendor/mglaman/phpstan-drupal/extension.neon + - vendor/phpstan/phpstan-deprecation-rules/rules.neon diff --git a/tests/travis-ci/fixtures/phpunit.xml.dist b/tests/travis-ci/fixtures/phpunit.xml.dist index ab8c9b7..3f1330c 100644 --- a/tests/travis-ci/fixtures/phpunit.xml.dist +++ b/tests/travis-ci/fixtures/phpunit.xml.dist @@ -1,33 +1,27 @@ - - - - - - - - - + + - + - ./modules/sparql_entity_storage + ./web/modules/sparql_entity_storage + diff --git a/tests/travis-ci/scripts/run_tests b/tests/travis-ci/scripts/run_tests deleted file mode 100755 index 798fc2f..0000000 --- a/tests/travis-ci/scripts/run_tests +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -case "$1" in - PHP_CodeSniffer) - cd ${SITE_DIR} - ./vendor/bin/phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer - ./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt --ignore='*.md' ${TRAVIS_BUILD_DIR} - exit $? - ;; - 8.*.x) - cd ${SITE_DIR}/web - ../vendor/bin/phpunit --testdox --verbose - exit $? - ;; - *) - echo "Unknown test '$1'" - exit 1 -esac diff --git a/tests/travis-ci/scripts/run_tests.sh b/tests/travis-ci/scripts/run_tests.sh new file mode 100644 index 0000000..a802e29 --- /dev/null +++ b/tests/travis-ci/scripts/run_tests.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +install_codebase () { + mkdir -p ${SITE_DIR}/web/modules + cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/composer.json.dist ${SITE_DIR}/composer.json + cd ${SITE_DIR} + perl -i -pe's/\$\{([^}]+)\}/$ENV{$1}/' composer.json + COMPOSER_MEMORY_LIMIT=-1 composer install --no-interaction --prefer-dist +} + +case "${TEST}" in + PHPCodeSniffer) + cd ${TRAVIS_BUILD_DIR} + composer install + ./vendor/bin/phpcs + exit $? + ;; + PHPStan) + # Deploy the codebase. + install_codebase + cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/phpstan.neon.dist ${SITE_DIR}/phpstan.neon + + # Run static analysis. + ./vendor/bin/phpstan analyse ./web/modules/sparql_entity_storage + exit $? + ;; + PHPUnit) + # Deploy the codebase. + install_codebase + + # Setup PHPUnit. + cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/phpunit.xml.dist ${SITE_DIR}/phpunit.xml + + # Virtuoso setup. + mkdir ${SITE_DIR}/virtuoso + docker run --name virtuoso -p 8890:8890 -p 1111:1111 -e SPARQL_UPDATE=true -v ${SITE_DIR}/virtuoso:/data -d tenforce/virtuoso + + # Create the MySQL database. + mysql -e 'CREATE DATABASE sparql_entity_storage_test' + mysql -e 'CREATE DATABASE sparql_entity_storage_test_phpunit' + + # Install Drupal. + ./vendor/bin/drush site:install testing --yes --root=${SITE_DIR}/web --db-url=mysql://root:@127.0.0.1/sparql_entity_storage_test + + # Add the SPARQL connection to settings.php. + chmod 0775 ${SITE_DIR}/web/sites/default/settings.php + cat ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/connection.txt >> ${SITE_DIR}/web/sites/default/settings.php + + # Enable the 'rdf_entity' module. + ./vendor/bin/drush pm:enable sparql_entity_storage --yes --root=${SITE_DIR}/web + + # Start the webserver for browser tests. + cd ${SITE_DIR}/web + nohup php -S localhost:8888 > /dev/null 2>&1 & + + # Wait until the web server is responding. + until curl -s localhost:8888; do true; done > /dev/null + + # Run PHPUnit. + cd .. + ./vendor/bin/phpunit --verbose + exit $? + ;; + *) + echo "Unknown test '$1'" + exit 1 +esac From 87dab933c375060247d2e19528265933bfb7e101 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Tue, 19 Jan 2021 22:11:14 +0200 Subject: [PATCH 09/23] ISAICP-5599: Make 'run_tests.sh' executable. --- tests/travis-ci/scripts/run_tests.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/travis-ci/scripts/run_tests.sh diff --git a/tests/travis-ci/scripts/run_tests.sh b/tests/travis-ci/scripts/run_tests.sh old mode 100644 new mode 100755 From 066478dab69297497acf379d3ee5324aa69a9b8d Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 00:01:18 +0200 Subject: [PATCH 10/23] ISAICP-5599: Big list of naughty strings does not have an installation candidate anymore. --- composer.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/composer.json b/composer.json index 2d9520d..8da5766 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,19 @@ "require-dev": { "minimaxir/big-list-of-naughty-strings": "dev-master" }, + "repositories": [ + { + "type": "package", + "package": { + "name": "minimaxir/big-list-of-naughty-strings", + "version": "dev-master", + "dist": { + "url": "https://github.com/minimaxir/big-list-of-naughty-strings/archive/master.zip", + "type": "zip" + } + } + } + ], "autoload": { "classmap": [ "src/Driver/Database/sparql/Connection.php" From 3f133c09e10465322ae9617ebda33ef11ac2ad64 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 01:16:02 +0200 Subject: [PATCH 11/23] ISAICP-5599: Request the rest of the packages. --- composer.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8da5766..e1a6556 100644 --- a/composer.json +++ b/composer.json @@ -8,12 +8,17 @@ "source": "https://cgit.drupalcode.org/sparql_entity_storage" }, "license": "GPL-2.0+", + "minimum-stability": "dev", + "prefer-stable": true, "require": { "easyrdf/easyrdf": "1.0.0 as 0.9.2", "ml/json-ld": "^1.0" }, "require-dev": { - "minimaxir/big-list-of-naughty-strings": "dev-master" + "minimaxir/big-list-of-naughty-strings": "dev-master", + "drupal/coder": "^8.3", + "mglaman/phpstan-drupal": "^0.12.6", + "phpstan/phpstan-deprecation-rules": "^0.12.5" }, "repositories": [ { From a8aa5bb412b41105111550deca89db98b806026f Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 10:49:14 +0200 Subject: [PATCH 12/23] ISAICP-5599: Provide the default rules/config for phpcs. --- phpcs-ruleset.xml.dist | 27 +++++++++++++++++++++++++++ phpcs.xml | 10 ++++++++++ 2 files changed, 37 insertions(+) create mode 100644 phpcs-ruleset.xml.dist create mode 100644 phpcs.xml diff --git a/phpcs-ruleset.xml.dist b/phpcs-ruleset.xml.dist new file mode 100644 index 0000000..f48b63f --- /dev/null +++ b/phpcs-ruleset.xml.dist @@ -0,0 +1,27 @@ + + + + + Drupal coding standard for contributed modules + + + *.gif + *.less + *.png + + + *.min.css + *.min.js + + + + + + + + + + + + + diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..7165f87 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,10 @@ + + + Default PHP CodeSniffer configuration for SPARQL Entity Storage. + + + + + . + ./vendor + From b0a05a7d267977c911e67afc8515fdd1fda76642 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 10:57:50 +0200 Subject: [PATCH 13/23] ISAICP-5599: Fix requirements for PHPStan. --- tests/travis-ci/fixtures/composer.json.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/travis-ci/fixtures/composer.json.dist b/tests/travis-ci/fixtures/composer.json.dist index 0ae8785..688507b 100644 --- a/tests/travis-ci/fixtures/composer.json.dist +++ b/tests/travis-ci/fixtures/composer.json.dist @@ -5,6 +5,7 @@ "drupal/core": "${DRUPAL}", "drupal/core-composer-scaffold": "*", "drupal/pathauto": "*", + "drupal/sparql_entity_storage": "*", "drupal/token": "*", "drush/drush": "~10", "easyrdf/easyrdf": "1.0.0 as 0.9.2", From 1d7e39041814b0b59fc80e9f3213e0fac4caef07 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 11:22:00 +0200 Subject: [PATCH 14/23] ISAICP-5599: Fix complaints by phpcs. --- src/DataCollector/SparqlDataCollector.php | 4 ++-- src/Entity/Query/Sparql/Query.php | 2 +- src/Entity/Query/Sparql/SparqlCondition.php | 6 +++--- src/SparqlEntityStorage.php | 4 ++-- tests/src/Kernel/SparqlEntityInsertTest.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/DataCollector/SparqlDataCollector.php b/src/DataCollector/SparqlDataCollector.php index 3521990..892f2aa 100644 --- a/src/DataCollector/SparqlDataCollector.php +++ b/src/DataCollector/SparqlDataCollector.php @@ -68,7 +68,7 @@ public function collect(Request $request, Response $response, \Exception $except $query_sort = $this->configFactory->get('webprofiler.config')->get('query_sort'); if ('duration' === $query_sort) { usort($queries, [ - "\\Drupal\\sparql_entity_storage\\DataCollector\\SparqlDataCollector", + SparqlDataCollector::class, "orderQueryByTime", ]); } @@ -254,7 +254,7 @@ public function getData() { * @return int * Sort for usort. */ - private function orderQueryByTime(array $a, array $b) { + protected function orderQueryByTime(array $a, array $b) { $at = $a['time']; $bt = $b['time']; diff --git a/src/Entity/Query/Sparql/Query.php b/src/Entity/Query/Sparql/Query.php index 9215946..6b1bdd1 100644 --- a/src/Entity/Query/Sparql/Query.php +++ b/src/Entity/Query/Sparql/Query.php @@ -245,7 +245,7 @@ protected function compile(): SparqlQueryInterface { // Remap the entity reference default tag to the SPARQL entity reference // because the first one requires that the query is an instance of the // SelectInterface. - // @todo: Maybe overwrite the default selection class? + // @todo Maybe overwrite the default selection class? if (isset($this->alterTags['entity_reference'])) { $this->alterTags['sparql_reference'] = $this->alterTags['entity_reference']; unset($this->alterTags['entity_reference']); diff --git a/src/Entity/Query/Sparql/SparqlCondition.php b/src/Entity/Query/Sparql/SparqlCondition.php index 582416f..75ea027 100644 --- a/src/Entity/Query/Sparql/SparqlCondition.php +++ b/src/Entity/Query/Sparql/SparqlCondition.php @@ -222,7 +222,7 @@ public function __construct($conjunction, SparqlQueryInterface $query, array $na /** * {@inheritdoc} * - * @todo: handle the lang. + * @todo handle the lang. */ public function condition($field = NULL, $value = NULL, $operator = NULL, $lang = NULL): self { if ($this->conjunction == 'OR') { @@ -296,7 +296,7 @@ public function condition($field = NULL, $value = NULL, $operator = NULL, $lang * Thrown if the value is NULL or the operator is not allowed. */ protected function keyCondition(string $field, $value, string $operator): self { - // @todo: Add support for loadMultiple with empty Id (load all). + // @todo Add support for loadMultiple with empty Id (load all). if ($value == NULL) { throw new \Exception('The value cannot be NULL for conditions related to the Id and bundle keys.'); } @@ -569,7 +569,7 @@ protected function addDefaultTriplePattern(): void { * @param array $condition * The query condition. * - * @todo: This could work generically but currently the term storage has + * @todo This could work generically but currently the term storage has * two possible predicates. This can be removed when we will be left with one * predicate for the term storage. */ diff --git a/src/SparqlEntityStorage.php b/src/SparqlEntityStorage.php index 872eb6f..04b19e5 100644 --- a/src/SparqlEntityStorage.php +++ b/src/SparqlEntityStorage.php @@ -302,7 +302,7 @@ protected function loadFromStorage(array $ids, array $graph_ids): ?array { return []; } - // @todo: We should filter per entity per graph and not load the whole + // @todo We should filter per entity per graph and not load the whole // database only to filter later on. // @see https://github.com/ec-europa/sparql_entity_storage/issues/2 $ids_string = SparqlArg::serializeUris($ids, ' '); @@ -1084,7 +1084,7 @@ public function hasData() { * @param array $values * The field values. * - * @todo: To be removed when columns will be supported. No need to manually + * @todo To be removed when columns will be supported. No need to manually * set this. */ protected function applyFieldDefaults($type, array &$values): void { diff --git a/tests/src/Kernel/SparqlEntityInsertTest.php b/tests/src/Kernel/SparqlEntityInsertTest.php index a716f40..3046389 100644 --- a/tests/src/Kernel/SparqlEntityInsertTest.php +++ b/tests/src/Kernel/SparqlEntityInsertTest.php @@ -141,8 +141,8 @@ public static function providerTestEntityInsertCallback(): array { * @return mixed * The retrieved value or NULL if no value exists. * - * @todo: Remove this when the deltas are supported. - * @todo: Discuss whether we need this in the storage level. + * @todo Remove this when the deltas are supported. + * @todo Discuss whether we need this in the storage level. */ protected function getEntityValue(ContentEntityInterface $entity, string $field_name) { $value = $entity->get($field_name)->getValue(); From 4eb64b439ce36412866773ac91ba27a0582b6201 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 12:10:46 +0200 Subject: [PATCH 15/23] ISAICP-5599: Fix the simpletest db url. --- tests/travis-ci/fixtures/phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/travis-ci/fixtures/phpunit.xml.dist b/tests/travis-ci/fixtures/phpunit.xml.dist index 3f1330c..8a68693 100644 --- a/tests/travis-ci/fixtures/phpunit.xml.dist +++ b/tests/travis-ci/fixtures/phpunit.xml.dist @@ -10,7 +10,7 @@ - + From 07bec917280fbeb613b271d9541e4e15117199b5 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 13:27:59 +0200 Subject: [PATCH 16/23] ISAICP-5599: Add verbosity to check the errors. --- tests/travis-ci/scripts/run_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/travis-ci/scripts/run_tests.sh b/tests/travis-ci/scripts/run_tests.sh index a802e29..fc29d0b 100755 --- a/tests/travis-ci/scripts/run_tests.sh +++ b/tests/travis-ci/scripts/run_tests.sh @@ -21,7 +21,7 @@ case "${TEST}" in cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/phpstan.neon.dist ${SITE_DIR}/phpstan.neon # Run static analysis. - ./vendor/bin/phpstan analyse ./web/modules/sparql_entity_storage + ./vendor/bin/phpstan analyse -vvv ./web/modules/sparql_entity_storage exit $? ;; PHPUnit) @@ -58,7 +58,7 @@ case "${TEST}" in # Run PHPUnit. cd .. - ./vendor/bin/phpunit --verbose + ./vendor/bin/phpunit --verbose --debug exit $? ;; *) From 32814c7d5532befc99d037484498f5d6713476fa Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 14:47:44 +0200 Subject: [PATCH 17/23] ISAICP-5599: Remove data collector class. --- src/DataCollector/SparqlDataCollector.php | 267 ---------------------- 1 file changed, 267 deletions(-) delete mode 100644 src/DataCollector/SparqlDataCollector.php diff --git a/src/DataCollector/SparqlDataCollector.php b/src/DataCollector/SparqlDataCollector.php deleted file mode 100644 index 892f2aa..0000000 --- a/src/DataCollector/SparqlDataCollector.php +++ /dev/null @@ -1,267 +0,0 @@ -database = $database; - $this->configFactory = $config_factory; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = NULL) { - $queries = $this->database->getLogger()->get('webprofiler'); - - foreach ($queries as &$query) { - // Remove caller args. - unset($query['caller']['args']); - - // Remove query args element if empty. - if (empty($query['args'])) { - unset($query['args']); - } - - // Save time in milliseconds. - $query['time'] = $query['time'] * 1000; - } - - $query_sort = $this->configFactory->get('webprofiler.config')->get('query_sort'); - if ('duration' === $query_sort) { - usort($queries, [ - SparqlDataCollector::class, - "orderQueryByTime", - ]); - } - - $this->data['queries'] = $queries; - - $options = $this->database->getConnectionOptions(); - - // Remove password for security. - unset($options['password']); - - $this->data['database'] = $options; - } - - /** - * Get database connection options. - * - * @return array - * Database connection options. - */ - public function getDatabase() { - return $this->data['database']; - } - - /** - * Return amount of queries ran. - * - * @return int - * Number of queries. - */ - public function getQueryCount() { - return count($this->data['queries']); - } - - /** - * Get all executed SPARQL queries. - * - * @return array - * List of SPARQL queries. - */ - public function getQueries() { - return $this->data['queries']; - } - - /** - * Returns the total execution time. - * - * @return float - * Time - */ - public function getTime() { - $time = 0; - - foreach ($this->data['queries'] as $query) { - $time += $query['time']; - } - - return $time; - } - - /** - * Returns a color based on the number of executed queries. - * - * @return string - * Color - */ - public function getColorCode() { - $count = $this->getQueryCount(); - $time = $this->getTime(); - if ($count < 10 && $time < 40) { - return 'green'; - } - if ($count < 20 && $time < 60) { - return 'yellow'; - } - - return 'red'; - } - - /** - * Returns the configured query highlight threshold. - * - * @return int - * Threshold - */ - public function getQueryHighlightThreshold() { - // When a profile is loaded from storage this object is deserialized and - // no constructor is called so we cannot use dependency injection. - return \Drupal::config('webprofiler.config')->get('query_highlight'); - } - - /** - * {@inheritdoc} - */ - public function getName() { - return 'sparql'; - } - - /** - * {@inheritdoc} - */ - public function getTitle() { - return $this->t('Sparql'); - } - - /** - * {@inheritdoc} - */ - public function getPanelSummary() { - return $this->t('Executed queries: @count', ['@count' => $this->getQueryCount()]); - } - - /** - * {@inheritdoc} - */ - public function getIcon() { - - return 'iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wseCQolVpASpQAAAc5JREFUSMe91jtoFFEYBeAvG3VFEwOi4KvSwifGQu3tglgoBC3UWmIKX62VTWzs1N7CgBC1tbCIoMX6CGiCiDZpLFRiQrCIht21+QPDshnuuhcvXAbmPzNn/sc5c8m7qriGGSzjJ8YxiEpmLrvwGs1V9oWcpFU8KSFb2YO5CE/hewLheK4U92NrAm4oF+H6RFx/LsI5NBJwn7ohWYOduI/fCf1r4krxBb3Yjr04gN0YWKV8e3A7smriDZ5ioYSsFtMM+nAZUwXAAh7geGDW4mgQrWT0ElexMTA38B5LEa/jGyaiGoQY75Z82SxGcAfzce85LmFbmwocxGjgpnAC64qAMwm1X47rJM5iR0J/m3jULjiZQFjHLWxKHKi+eG6iNVAp9KhsVaJvi93qJ7uDpxDWEnCNkMNADtLTHQzNC5wrjninQ9OLz9hS0stZ3AxbGsJFHMEGfMWvFvwhDOMk/uBL4OqtUzWCd4Ws5kP4x1qEP1YQ9itcR39B+B8K8Ub8th63q0qn1jYWX93E206trRvzvvev5t3NGi1kW7anc+lwc6Km9+UiXErELeYi/IgfCbhn//uYeDj3QbhWQnYePbm9uRqjPx12OIeHkVkP/AVSbdRhDiH9kwAAAABJRU5ErkJggg=='; - } - - /** - * {@inheritdoc} - */ - public function getLibraries() { - return [ - 'webprofiler/database', - ]; - } - - /** - * {@inheritdoc} - */ - public function getData() { - $data = $this->data; - $conn = Database::getConnection(); - foreach ($data['queries'] as &$query) { - $explain = TRUE; - $type = 'select'; - - if (strpos($query['query'], 'INSERT') !== FALSE) { - $explain = FALSE; - $type = 'insert'; - } - - if (strpos($query['query'], 'UPDATE') !== FALSE) { - $explain = FALSE; - $type = 'update'; - } - - if (strpos($query['query'], 'CREATE') !== FALSE) { - $explain = FALSE; - $type = 'create'; - } - - if (strpos($query['query'], 'DELETE') !== FALSE) { - $explain = FALSE; - $type = 'delete'; - } - - $query['explain'] = $explain; - $query['type'] = $type; - - $quoted = []; - foreach ((array) $query['args'] as $key => $val) { - $quoted[$key] = is_null($val) ? 'NULL' : $conn->quote($val); - } - - $query['query_args'] = strtr($query['query'], $quoted); - } - - $data['query_highlight_threshold'] = $this->getQueryHighlightThreshold(); - return $data; - } - - /** - * Sort callback. Sort queries by timing. - * - * @param array $a - * Query. - * @param array $b - * Query. - * - * @return int - * Sort for usort. - */ - protected function orderQueryByTime(array $a, array $b) { - $at = $a['time']; - $bt = $b['time']; - - if ($at == $bt) { - return 0; - } - return ($at < $bt) ? 1 : -1; - } - -} From d32e5cde5779197d40d2e8d894324105db943564 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 20 Jan 2021 15:44:33 +0200 Subject: [PATCH 18/23] ISAICP-5599: Remove verbosity check. --- tests/travis-ci/scripts/run_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/travis-ci/scripts/run_tests.sh b/tests/travis-ci/scripts/run_tests.sh index fc29d0b..a802e29 100755 --- a/tests/travis-ci/scripts/run_tests.sh +++ b/tests/travis-ci/scripts/run_tests.sh @@ -21,7 +21,7 @@ case "${TEST}" in cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/phpstan.neon.dist ${SITE_DIR}/phpstan.neon # Run static analysis. - ./vendor/bin/phpstan analyse -vvv ./web/modules/sparql_entity_storage + ./vendor/bin/phpstan analyse ./web/modules/sparql_entity_storage exit $? ;; PHPUnit) @@ -58,7 +58,7 @@ case "${TEST}" in # Run PHPUnit. cd .. - ./vendor/bin/phpunit --verbose --debug + ./vendor/bin/phpunit --verbose exit $? ;; *) From bc8467cf3f7e37ad5161eb9506b5a161c7366cdc Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Thu, 28 Jan 2021 23:14:53 +0200 Subject: [PATCH 19/23] Test the sparql endpoint. --- tests/travis-ci/scripts/run_tests.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/travis-ci/scripts/run_tests.sh b/tests/travis-ci/scripts/run_tests.sh index a802e29..b0cd76a 100755 --- a/tests/travis-ci/scripts/run_tests.sh +++ b/tests/travis-ci/scripts/run_tests.sh @@ -46,6 +46,9 @@ case "${TEST}" in chmod 0775 ${SITE_DIR}/web/sites/default/settings.php cat ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/connection.txt >> ${SITE_DIR}/web/sites/default/settings.php + # Test the SPARQL endpoint. + curl "localhost:8890/sparql?default-graph-uri=&query=select+distinct+%3FConcept+where+%7B%5B%5D+a+%3FConcept%7D+LIMIT+100&should-sponge=&format=text%2Fhtml" + # Enable the 'rdf_entity' module. ./vendor/bin/drush pm:enable sparql_entity_storage --yes --root=${SITE_DIR}/web From 19c742150e529c9eb1d17425ea7b82f389dd455e Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Thu, 28 Jan 2021 23:48:26 +0200 Subject: [PATCH 20/23] Cancel the rest of the tests for now. --- .travis.yml | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4613d16..4a8310d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: php php: - - '7.2' + # - '7.2' - '7.3' - - '7.4' + # - '7.4' sudo: required @@ -20,30 +20,29 @@ env: global: - SITE_DIR="$HOME/build/testing_site" matrix: - - TEST=PHPCodeSniffer - - TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 + # - TEST=PHPCodeSniffer - TEST=PHPUnit DRUPAL=~8.9.0 PHPUNIT=^7 - - TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 - - TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 - - TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 + # - TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 + # - TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 + # - TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 matrix: fast_finish: true exclude: - - php: '7.2' - env: TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 - - php: '7.2' - env: TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 - - php: '7.2' - env: TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 + # - php: '7.2' + # env: TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 + # - php: '7.2' + # env: TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 + # - php: '7.2' + # env: TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 + # - php: '7.3' + # env: TEST=PHPCodeSniffer - php: '7.3' - env: TEST=PHPCodeSniffer - - php: '7.3' - env: TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 - - php: '7.4' - env: TEST=PHPCodeSniffer - - php: '7.4' env: TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 + # - php: '7.4' + # env: TEST=PHPCodeSniffer + # - php: '7.4' + # env: TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 before_install: # Remove this line to run with Xdebug enabled. From f7ad3819e54a76274b9122d82c0d41d04a71dfe2 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Fri, 29 Jan 2021 09:51:36 +0200 Subject: [PATCH 21/23] Use the internal address as in every other place. --- tests/travis-ci/scripts/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/travis-ci/scripts/run_tests.sh b/tests/travis-ci/scripts/run_tests.sh index b0cd76a..285fbc0 100755 --- a/tests/travis-ci/scripts/run_tests.sh +++ b/tests/travis-ci/scripts/run_tests.sh @@ -47,7 +47,7 @@ case "${TEST}" in cat ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/connection.txt >> ${SITE_DIR}/web/sites/default/settings.php # Test the SPARQL endpoint. - curl "localhost:8890/sparql?default-graph-uri=&query=select+distinct+%3FConcept+where+%7B%5B%5D+a+%3FConcept%7D+LIMIT+100&should-sponge=&format=text%2Fhtml" + curl -v "127.0.0.1:8890/sparql?default-graph-uri=&query=select+distinct+%3FConcept+where+%7B%5B%5D+a+%3FConcept%7D+LIMIT+100&should-sponge=&format=text%2Fhtml" # Enable the 'rdf_entity' module. ./vendor/bin/drush pm:enable sparql_entity_storage --yes --root=${SITE_DIR}/web From 9ea192b34af75e192f2da9711b2f7f9783dcf681 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Fri, 29 Jan 2021 11:35:09 +0200 Subject: [PATCH 22/23] Sleep to ensure docker service is available. --- tests/travis-ci/scripts/run_tests.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/travis-ci/scripts/run_tests.sh b/tests/travis-ci/scripts/run_tests.sh index 285fbc0..ac1ba82 100755 --- a/tests/travis-ci/scripts/run_tests.sh +++ b/tests/travis-ci/scripts/run_tests.sh @@ -35,6 +35,9 @@ case "${TEST}" in mkdir ${SITE_DIR}/virtuoso docker run --name virtuoso -p 8890:8890 -p 1111:1111 -e SPARQL_UPDATE=true -v ${SITE_DIR}/virtuoso:/data -d tenforce/virtuoso + # Sleep to ensure that docker services are available. + sleep 15 + # Create the MySQL database. mysql -e 'CREATE DATABASE sparql_entity_storage_test' mysql -e 'CREATE DATABASE sparql_entity_storage_test_phpunit' From 8ae306f9df082a022ccc79a6242f4eb0e92d7d21 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Fri, 29 Jan 2021 11:40:49 +0200 Subject: [PATCH 23/23] Remove uneeded patch, uncomment tests. Remove debug code. --- .travis.yml | 37 +++++++++++---------- tests/travis-ci/fixtures/composer.json.dist | 5 --- tests/travis-ci/scripts/run_tests.sh | 3 -- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a8310d..4613d16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: php php: - # - '7.2' + - '7.2' - '7.3' - # - '7.4' + - '7.4' sudo: required @@ -20,29 +20,30 @@ env: global: - SITE_DIR="$HOME/build/testing_site" matrix: - # - TEST=PHPCodeSniffer + - TEST=PHPCodeSniffer + - TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 - TEST=PHPUnit DRUPAL=~8.9.0 PHPUNIT=^7 - # - TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 - # - TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 - # - TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 + - TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 + - TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 + - TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 matrix: fast_finish: true exclude: - # - php: '7.2' - # env: TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 - # - php: '7.2' - # env: TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 - # - php: '7.2' - # env: TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 - # - php: '7.3' - # env: TEST=PHPCodeSniffer + - php: '7.2' + env: TEST=PHPUnit DRUPAL=~9.0.0 PHPUNIT=^8 + - php: '7.2' + env: TEST=PHPUnit DRUPAL=~9.1.0 PHPUNIT=^8 + - php: '7.2' + env: TEST=PHPUnit DRUPAL=~9.2.0 PHPUNIT=^8 - php: '7.3' + env: TEST=PHPCodeSniffer + - php: '7.3' + env: TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 + - php: '7.4' + env: TEST=PHPCodeSniffer + - php: '7.4' env: TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 - # - php: '7.4' - # env: TEST=PHPCodeSniffer - # - php: '7.4' - # env: TEST=PHPStan DRUPAL=~8.9.0 PHPUNIT=^7 before_install: # Remove this line to run with Xdebug enabled. diff --git a/tests/travis-ci/fixtures/composer.json.dist b/tests/travis-ci/fixtures/composer.json.dist index 688507b..be8721f 100644 --- a/tests/travis-ci/fixtures/composer.json.dist +++ b/tests/travis-ci/fixtures/composer.json.dist @@ -53,11 +53,6 @@ "locations": { "web-root": "web/" } - }, - "patches": { - "drupal/core": { - "Bundle label plural variants @see https://www.drupal.org/node/2765065": "https://www.drupal.org/files/issues/2018-06-11/2765065-93.patch" - } } } } diff --git a/tests/travis-ci/scripts/run_tests.sh b/tests/travis-ci/scripts/run_tests.sh index ac1ba82..67612a0 100755 --- a/tests/travis-ci/scripts/run_tests.sh +++ b/tests/travis-ci/scripts/run_tests.sh @@ -49,9 +49,6 @@ case "${TEST}" in chmod 0775 ${SITE_DIR}/web/sites/default/settings.php cat ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/connection.txt >> ${SITE_DIR}/web/sites/default/settings.php - # Test the SPARQL endpoint. - curl -v "127.0.0.1:8890/sparql?default-graph-uri=&query=select+distinct+%3FConcept+where+%7B%5B%5D+a+%3FConcept%7D+LIMIT+100&should-sponge=&format=text%2Fhtml" - # Enable the 'rdf_entity' module. ./vendor/bin/drush pm:enable sparql_entity_storage --yes --root=${SITE_DIR}/web