From 8e8b369b3b9272d6597513c3f40b405e9c72b9e7 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 15 Oct 2020 16:34:49 +1300 Subject: [PATCH 1/4] NEW: Confirm support for composer 2. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No changes appear to have been necessary to get the plugin’s test suite passing. --- .travis.yml | 16 ++++++++++++---- composer.json | 8 ++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14ffcf2..e0b7c33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,17 +8,25 @@ cache: matrix: include: - - php: 5.6 - - php: 7.2 + - php: 7.1 + env: + - COMPOSER_SELFUPDATE_ARG=--1 + - COMPOSER_ARG=--prefer-lowest + - php: 7.3 + env: + - COMPOSER_SELFUPDATE_ARG=--1 + - php: 7.4 + env: + - COMPOSER_SELFUPDATE_ARG=--preview fast_finish: true before_script: - phpenv rehash - export PATH=~/.composer/vendor/bin:$PATH + - composer self-update $COMPOSER_SELFUPDATE_ARG - composer validate - - composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o - - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile + - composer update --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile $COMPOSER_ARG script: - vendor/bin/phpunit diff --git a/composer.json b/composer.json index 91d401f..9062561 100644 --- a/composer.json +++ b/composer.json @@ -25,13 +25,13 @@ "lint": "phpcs src/ tests/", "lint-clean": "phpcbf src/ tests/" }, - "minimum-stability": "dev", "require": { "composer/installers": "^1.4", - "composer-plugin-api": "^1.1" + "composer-plugin-api": "^1.1 || ^2" }, "require-dev": { - "composer/composer": "^1.5", - "phpunit/phpunit": "^5.7" + "composer/composer": "^1.5 || ^2@rc", + "phpunit/phpunit": "^5.7", + "squizlabs/php_codesniffer": "^3" } } From f29fb9ef7db921f413aa4fd9e16aa987737e98fd Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 20 Oct 2020 16:28:02 +1300 Subject: [PATCH 2/4] FIX: Clarify PHP version support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Align with the test matrix by requiring at least PHP 7.1. Add PHP 8 to the matrix since we’re rolling it out across other Silverstripe packages. --- .travis.yml | 4 ++++ composer.json | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e0b7c33..6eb71e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,10 @@ matrix: - php: 7.4 env: - COMPOSER_SELFUPDATE_ARG=--preview + - php: nightly + env: + - COMPOSER_ARG=--ignore-platform-reqs + - COMPOSER_SELFUPDATE_ARG=--preview fast_finish: true diff --git a/composer.json b/composer.json index 9062561..6834f29 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ }, "require": { "composer/installers": "^1.4", - "composer-plugin-api": "^1.1 || ^2" + "composer-plugin-api": "^1.1 || ^2", + "php": "^7.1 || ^8" }, "require-dev": { "composer/composer": "^1.5 || ^2@rc", From 6a15370aae8452a3036900e524ed2acee07b7ad2 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 22 Oct 2020 14:47:29 +1300 Subject: [PATCH 3/4] FIX: Add missing methods to plugin interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the original composer2 fix, these were missed. Funnily enough, our test suite didn’t cover even this case so I’ve added a minimal failing test that checks instantiation works. --- src/VendorPlugin.php | 14 ++++++++++++++ tests/VendorPluginTest.php | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/VendorPluginTest.php diff --git a/src/VendorPlugin.php b/src/VendorPlugin.php index 438e8e7..0fbd46c 100644 --- a/src/VendorPlugin.php +++ b/src/VendorPlugin.php @@ -248,4 +248,18 @@ protected function installLibrary(IOInterface $IO, Library $library) ); $task->process($IO, [$library]); } + + /** + * Required by the composer 2 plugin interface + */ + public function deactivate(Composer $composer, IOInterface $io) + { + } + + /** + * Required by the composer 2 plugin interface + */ + public function uninstall(Composer $composer, IOInterface $io) + { + } } diff --git a/tests/VendorPluginTest.php b/tests/VendorPluginTest.php new file mode 100644 index 0000000..259b141 --- /dev/null +++ b/tests/VendorPluginTest.php @@ -0,0 +1,17 @@ + Date: Mon, 26 Oct 2020 14:12:56 +1300 Subject: [PATCH 4/4] FIX Correct paths for fixtures in LibraryTest --- tests/Methods/LibraryTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Methods/LibraryTest.php b/tests/Methods/LibraryTest.php index f375e39..a54cf18 100644 --- a/tests/Methods/LibraryTest.php +++ b/tests/Methods/LibraryTest.php @@ -12,7 +12,7 @@ class LibraryTest extends TestCase */ public function testResourcesDir($expected, $projectPath) { - $path = __DIR__ . '/fixtures/projects/' . $projectPath; + $path = __DIR__ . '/../fixtures/projects/' . $projectPath; $lib = new Library($path, 'vendor/silverstripe/skynet'); $this->assertEquals($expected, $lib->getResourcesDir()); } @@ -29,7 +29,7 @@ public function resourcesDirProvider() public function testInvalidResourceDir() { $this->expectException(\LogicException::class); - $path = __DIR__ . '/fixtures/projects/ss44InvalidResourcesDir'; + $path = __DIR__ . '/../fixtures/projects/ss44InvalidResourcesDir'; $lib = new Library($path, 'vendor/silverstripe/skynet'); $lib->getResourcesDir(); }