From 90035a99ee795a4989cfcc86d9ac45ea4ad29cb2 Mon Sep 17 00:00:00 2001 From: recca0120 Date: Tue, 27 Oct 2020 17:44:42 +0800 Subject: [PATCH 01/12] must be absolute path --- tests/unitTests/AbstractDiscoveryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unitTests/AbstractDiscoveryTest.php b/tests/unitTests/AbstractDiscoveryTest.php index 0758004..5a20f74 100644 --- a/tests/unitTests/AbstractDiscoveryTest.php +++ b/tests/unitTests/AbstractDiscoveryTest.php @@ -24,7 +24,7 @@ protected function getInstallationManagerMock(string $installPath = null) : Inst // Configure the stub. $installationManager->method('getInstallPath') - ->willReturn($installPath ?? 'tests/fixtures/package_a'); + ->willReturn(realpath($installPath ?? 'tests/fixtures/package_a')); return $installationManager; } From 6b8501274519e4a1da42c9fdc85ab06969bf6da2 Mon Sep 17 00:00:00 2001 From: recca0120 Date: Tue, 27 Oct 2020 17:50:20 +0800 Subject: [PATCH 02/12] composer 2 --- .travis.yml | 2 +- composer.json | 4 ++-- src/DiscoveryPlugin.php | 10 ++++++++++ tests/unitTests/PackagesOrdererTest.php | 5 +++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f331730..127d620 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ php: - 7.1 - 7.2 before_script: -- composer self-update +- composer self-update --snapshot - composer clear-cache - composer update env: diff --git a/composer.json b/composer.json index 2e8081f..b72e74a 100644 --- a/composer.json +++ b/composer.json @@ -14,10 +14,10 @@ ], "require": { "php": ">=7.0.0", - "composer-plugin-api": "^1.0" + "composer-plugin-api": "^1.0 || ^2.0" }, "require-dev": { - "composer/composer": "^1.0", + "composer/composer": "^1.0 || ^2.0", "satooshi/php-coveralls": "^1.0", "phpunit/phpunit": "~5.0", "humbug/humbug": "~1.0", diff --git a/src/DiscoveryPlugin.php b/src/DiscoveryPlugin.php index bffc06b..90ac5bd 100644 --- a/src/DiscoveryPlugin.php +++ b/src/DiscoveryPlugin.php @@ -94,4 +94,14 @@ public function getCapabilities() CommandProvider::class => DiscoveryCommandProvider::class, ]; } + + public function deactivate(Composer $composer, IOInterface $io) + { + // TODO: Implement deactivate() method. + } + + public function uninstall(Composer $composer, IOInterface $io) + { + // TODO: Implement uninstall() method. + } } diff --git a/tests/unitTests/PackagesOrdererTest.php b/tests/unitTests/PackagesOrdererTest.php index c4b2d44..58452b4 100644 --- a/tests/unitTests/PackagesOrdererTest.php +++ b/tests/unitTests/PackagesOrdererTest.php @@ -3,6 +3,7 @@ namespace TheCodingMachine\Discovery; +use Composer\Semver\Constraint\Constraint; use Composer\Semver\VersionParser; use Composer\Package\Link; use Composer\TestCase; @@ -36,10 +37,10 @@ public function testOrderer() /* @var $packageB \Composer\Package\Package */ /* @var $packageC \Composer\Package\Package */ $packageB->setRequires([ - new Link('package/b', 'package/za') + new Link('package/b', 'package/za', new Constraint('=', '*')) ]); $packageC->setRequires([ - new Link('package/c', 'package/b') + new Link('package/c', 'package/b', new Constraint('=', '*')) ]); $result = PackagesOrderer::reorderPackages([$packageC, $packageB, $packageA]); From 1049e77c6048b46cad4b296cd16a6ffc3981f203 Mon Sep 17 00:00:00 2001 From: recca0120 Date: Tue, 27 Oct 2020 18:05:43 +0800 Subject: [PATCH 03/12] phpunit 6 --- .travis.yml | 2 +- composer.json | 7 ++++++- tests/unitTests/AbstractDiscoveryTest.php | 6 +++--- tests/unitTests/AssetOperationTest.php | 8 ++++++-- tests/unitTests/AssetTest.php | 7 +++++-- tests/unitTests/AssetTypeTest.php | 9 +++++++-- tests/unitTests/AssetsBuilderTest.php | 3 ++- tests/unitTests/Commands/AddAssetCommandTest.php | 10 +++------- tests/unitTests/Commands/CommandProviderTest.php | 6 ++++-- tests/unitTests/Commands/DumpCommandTest.php | 12 +++--------- .../unitTests/Commands/ListAssetTypesCommandTest.php | 10 +++------- tests/unitTests/Commands/RemoveAssetCommandTest.php | 12 ++++-------- tests/unitTests/DiscoveryFileLoaderTest.php | 3 ++- tests/unitTests/DiscoveryTest.php | 7 +++++-- tests/unitTests/DumperTest.php | 4 +++- tests/unitTests/ImmutableAssetTypeTest.php | 7 +++++-- tests/unitTests/PackagesOrdererTest.php | 7 ++++--- 17 files changed, 66 insertions(+), 54 deletions(-) diff --git a/.travis.yml b/.travis.yml index 127d620..e1da6e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ php: - 7.1 - 7.2 before_script: -- composer self-update --snapshot +- composer self-update --2 - composer clear-cache - composer update env: diff --git a/composer.json b/composer.json index b72e74a..1066c96 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require-dev": { "composer/composer": "^1.0 || ^2.0", "satooshi/php-coveralls": "^1.0", - "phpunit/phpunit": "~5.0", + "phpunit/phpunit": "~6.0", "humbug/humbug": "~1.0", "squizlabs/php_codesniffer": "^2.7.0", "couscous/couscous": "^1.6" @@ -29,6 +29,11 @@ "TheCodingMachine\\Discovery\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "TheCodingMachine\\Discovery\\Tests\\": "tests/unitTests" + } + }, "extra": { "class": "TheCodingMachine\\Discovery\\DiscoveryPlugin", "branch-alias": { diff --git a/tests/unitTests/AbstractDiscoveryTest.php b/tests/unitTests/AbstractDiscoveryTest.php index 5a20f74..489c5f5 100644 --- a/tests/unitTests/AbstractDiscoveryTest.php +++ b/tests/unitTests/AbstractDiscoveryTest.php @@ -1,7 +1,7 @@ Date: Tue, 27 Oct 2020 22:38:41 +0800 Subject: [PATCH 04/12] scrutinizer config --- .scrutinizer.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..6495df9 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,22 @@ +checks: + php: true + +build: + nodes: + my-tests: + dependencies: + before: + - cd tests && ./run.sh + environment: + php: + version: "7.2" + analysis: + tests: + override: + - php-scrutinizer-run + +filter: + paths: + - "src/*" + - "tests/*" + From 3aefad41a3a13003ece171bb48ba900abde7d357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 10 Apr 2020 17:37:34 +0200 Subject: [PATCH 05/12] Upgrading plugin to Composer 2 --- src/DiscoveryPlugin.php | 10 ++++++++-- tests/composer-test.json | 2 +- tests/run.sh | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/DiscoveryPlugin.php b/src/DiscoveryPlugin.php index 90ac5bd..35269e5 100644 --- a/src/DiscoveryPlugin.php +++ b/src/DiscoveryPlugin.php @@ -95,13 +95,19 @@ public function getCapabilities() ]; } + /** + * @inheritDoc + */ public function deactivate(Composer $composer, IOInterface $io) { - // TODO: Implement deactivate() method. + } + /** + * @inheritDoc + */ public function uninstall(Composer $composer, IOInterface $io) { - // TODO: Implement uninstall() method. + } } diff --git a/tests/composer-test.json b/tests/composer-test.json index 48eca8f..e0eadaf 100644 --- a/tests/composer-test.json +++ b/tests/composer-test.json @@ -18,4 +18,4 @@ "thecodingmachine/discovery": "*", "package/b": "*" } -} \ No newline at end of file +} diff --git a/tests/run.sh b/tests/run.sh index 9b5e3dd..45b4a02 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -5,6 +5,6 @@ set -e # Lets copy the code in a subdirectory of the tests, otherwise Composer cannot require the package. rsync -av .. fixtures/copy/ --exclude tests --exclude vendor -COMPOSER=composer-test.json composer update -v +COMPOSER=composer-test.json composer update -vvv #rm -rf fixtures/copy From 0f5e2c37a07dd99ded7db9fd4676e391723c3862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 27 Oct 2020 16:55:44 +0100 Subject: [PATCH 06/12] Upgrading all dependencies: - switching from PHPUnit 5 to PHPUnit 8 - switching from Humbug to Infection - Minimum version now: PHP 7.2 --- .travis.yml | 4 ++-- composer.json | 17 +++++++++-------- infection.json.dist | 16 ++++++++++++++++ phpunit.xml.dist | 3 +-- src/AssetsBuilder.php | 2 +- tests/unitTests/AssetOperationTest.php | 2 +- tests/unitTests/AssetTest.php | 1 - tests/unitTests/AssetTypeTest.php | 5 +---- .../unitTests/Commands/AddAssetCommandTest.php | 2 +- tests/unitTests/Commands/DumpCommandTest.php | 2 +- .../Commands/ListAssetTypesCommandTest.php | 14 +++++++------- .../Commands/RemoveAssetCommandTest.php | 2 +- tests/unitTests/DiscoveryTest.php | 5 ++--- tests/unitTests/ImmutableAssetTypeTest.php | 3 +-- 14 files changed, 44 insertions(+), 34 deletions(-) create mode 100644 infection.json.dist diff --git a/.travis.yml b/.travis.yml index e1da6e1..233c4d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: - cd ..; vendor/bin/phpunit - "./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/unitTests --config-set ignore_warnings_on_exit 1" -- "./vendor/bin/humbug" +- "./vendor/bin/infection" after_script: -- php vendor/bin/coveralls -v +- php vendor/bin/php-coveralls -v - "./vendor/bin/couscous travis-auto-deploy --php-version=7.1" diff --git a/composer.json b/composer.json index 1066c96..0150fa6 100644 --- a/composer.json +++ b/composer.json @@ -13,16 +13,17 @@ } ], "require": { - "php": ">=7.0.0", + "php": ">=7.2", "composer-plugin-api": "^1.0 || ^2.0" }, "require-dev": { - "composer/composer": "^1.0 || ^2.0", - "satooshi/php-coveralls": "^1.0", - "phpunit/phpunit": "~6.0", - "humbug/humbug": "~1.0", - "squizlabs/php_codesniffer": "^2.7.0", - "couscous/couscous": "^1.6" + "composer/composer": "^1 || ^2", + "composer/semver": "^1 || ^2 || ^3", + "php-coveralls/php-coveralls": "^2.4.2", + "phpunit/phpunit": "^8.5.8", + "squizlabs/php_codesniffer": "^2.9.2", + "couscous/couscous": "^1.8", + "infection/infection": "^0.18.2" }, "autoload": { "psr-4": { @@ -37,7 +38,7 @@ "extra": { "class": "TheCodingMachine\\Discovery\\DiscoveryPlugin", "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.3.x-dev" } }, "minimum-stability": "alpha", diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 0000000..06a97aa --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,16 @@ +{ + "source": { + "directories": [ + "src" + ] + }, + "timeout": 15, + "logs": { + "text": "infection-log.txt", + "summary": "summary-log.txt", + "debug": "debug-log.txt" + }, + "phpUnit": { + "configDir": "." + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9360f50..179e6f3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,7 +8,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > @@ -26,7 +25,7 @@ - + diff --git a/src/AssetsBuilder.php b/src/AssetsBuilder.php index 139511d..7cda190 100644 --- a/src/AssetsBuilder.php +++ b/src/AssetsBuilder.php @@ -116,7 +116,7 @@ private function getDiscoveryJson(PackageInterface $package) : array $fileSystem = new Filesystem(); - $packageDir = $fileSystem->makePathRelative($packageInstallPath, realpath($this->rootDir)); + $packageDir = $fileSystem->makePathRelative(realpath($packageInstallPath), realpath($this->rootDir)); $path = $packageInstallPath.'/discovery.json'; diff --git a/tests/unitTests/AssetOperationTest.php b/tests/unitTests/AssetOperationTest.php index 4c31b05..4c5fc7d 100644 --- a/tests/unitTests/AssetOperationTest.php +++ b/tests/unitTests/AssetOperationTest.php @@ -3,8 +3,8 @@ namespace TheCodingMachine\Discovery\Tests; -use InvalidArgumentException; use PHPUnit\Framework\TestCase; +use InvalidArgumentException; use TheCodingMachine\Discovery\Asset; use TheCodingMachine\Discovery\AssetOperation; use TheCodingMachine\Discovery\Utils\JsonException; diff --git a/tests/unitTests/AssetTest.php b/tests/unitTests/AssetTest.php index dfe1c82..d06655e 100644 --- a/tests/unitTests/AssetTest.php +++ b/tests/unitTests/AssetTest.php @@ -4,7 +4,6 @@ use PHPUnit\Framework\TestCase; -use TheCodingMachine\Discovery\Asset; class AssetTest extends TestCase { diff --git a/tests/unitTests/AssetTypeTest.php b/tests/unitTests/AssetTypeTest.php index 37ba359..b81094a 100644 --- a/tests/unitTests/AssetTypeTest.php +++ b/tests/unitTests/AssetTypeTest.php @@ -1,12 +1,9 @@ callCommand(new AddAssetCommand(), $input); - $this->assertContains('The priority must be a numeric value.', $result); + $this->assertStringContainsString('The priority must be a numeric value.', $result); } diff --git a/tests/unitTests/Commands/DumpCommandTest.php b/tests/unitTests/Commands/DumpCommandTest.php index 42e3186..430f8f2 100644 --- a/tests/unitTests/Commands/DumpCommandTest.php +++ b/tests/unitTests/Commands/DumpCommandTest.php @@ -18,7 +18,7 @@ public function testCall() $result = $this->callCommand(new DumpCommand(), $input); - $this->assertContains('Discovery files successfully dumped in the .discovery directory.', $result); + $this->assertStringContainsString('Discovery files successfully dumped in the .discovery directory.', $result); } } diff --git a/tests/unitTests/Commands/ListAssetTypesCommandTest.php b/tests/unitTests/Commands/ListAssetTypesCommandTest.php index 9f5d43f..046c80f 100644 --- a/tests/unitTests/Commands/ListAssetTypesCommandTest.php +++ b/tests/unitTests/Commands/ListAssetTypesCommandTest.php @@ -27,9 +27,9 @@ public function testEmptyCall() $result = $this->callCommand(new ListAssetTypesCommand(), $input); - $this->assertContains('test-asset:', $result); - $this->assertContains('a1', $result); - $this->assertContains('a2', $result); + $this->assertStringContainsString('test-asset:', $result); + $this->assertStringContainsString('a1', $result); + $this->assertStringContainsString('a2', $result); } public function testWithAssetType() @@ -38,9 +38,9 @@ public function testWithAssetType() $result = $this->callCommand(new ListAssetTypesCommand(), $input); - $this->assertContains('test-asset:', $result); - $this->assertContains('a1', $result); - $this->assertContains('a2', $result); + $this->assertStringContainsString('test-asset:', $result); + $this->assertStringContainsString('a1', $result); + $this->assertStringContainsString('a2', $result); } public function testJson() @@ -59,6 +59,6 @@ public function testNoAssetType() $result = $this->callCommand(new ListAssetTypesCommand(), $input); - $this->assertContains('Could not find the "toto" asset type.', $result); + $this->assertStringContainsString('Could not find the "toto" asset type.', $result); } } diff --git a/tests/unitTests/Commands/RemoveAssetCommandTest.php b/tests/unitTests/Commands/RemoveAssetCommandTest.php index 3da00c8..e6b7d85 100644 --- a/tests/unitTests/Commands/RemoveAssetCommandTest.php +++ b/tests/unitTests/Commands/RemoveAssetCommandTest.php @@ -61,7 +61,7 @@ public function testRemoveNonExistingFromProject() $result = $this->callCommand(new RemoveAssetCommand(), $input); - $this->assertContains('There is no asset "not-exist" in asset type "not-exist".', $result); + $this->assertStringContainsString('There is no asset "not-exist" in asset type "not-exist".', $result); } public function testRemoveFromProject() diff --git a/tests/unitTests/DiscoveryTest.php b/tests/unitTests/DiscoveryTest.php index a6c3e25..a527bff 100644 --- a/tests/unitTests/DiscoveryTest.php +++ b/tests/unitTests/DiscoveryTest.php @@ -1,14 +1,13 @@ Date: Tue, 27 Oct 2020 17:02:51 +0100 Subject: [PATCH 07/12] Upgrading PHP version --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 233c4d7..a8aa171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: php php: - - 7.0 - - 7.1 - - 7.2 + - 7.3 + - 7.4 before_script: - composer self-update --2 - composer clear-cache From ede667b8fb68458f157eb1bfe1e4bf2da275b68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 27 Oct 2020 17:19:26 +0100 Subject: [PATCH 08/12] Fixing namespace --- tests/unitTests/AssetTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unitTests/AssetTest.php b/tests/unitTests/AssetTest.php index d06655e..e771e13 100644 --- a/tests/unitTests/AssetTest.php +++ b/tests/unitTests/AssetTest.php @@ -1,6 +1,6 @@ Date: Tue, 27 Oct 2020 17:30:13 +0100 Subject: [PATCH 09/12] Fixing build --- .travis.yml | 2 +- tests/unitTests/DiscoveryTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8aa171..0d1c08a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php php: - - 7.3 + #- 7.3 - 7.4 before_script: - composer self-update --2 diff --git a/tests/unitTests/DiscoveryTest.php b/tests/unitTests/DiscoveryTest.php index a527bff..20736ea 100644 --- a/tests/unitTests/DiscoveryTest.php +++ b/tests/unitTests/DiscoveryTest.php @@ -39,7 +39,7 @@ public function testAssetType() $this->assertSame('a1', $result->getAssets()[0]->getValue()); $this->assertSame('package/a', $result->getAssets()[0]->getPackage()); - $this->assertSame('vendor/package/a/', $result->getAssets()[0]->getPackageDir()); + $this->assertSame('fixtures/package_a/', $result->getAssets()[0]->getPackageDir()); } public function testEmptyAssetType() From addbdf49dd46795663e3e4239cc4757e54c13ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 27 Oct 2020 17:35:27 +0100 Subject: [PATCH 10/12] Upgrading minimum version for Scrutinizer --- .scrutinizer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 6495df9..f04bd4b 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -9,7 +9,7 @@ build: - cd tests && ./run.sh environment: php: - version: "7.2" + version: "7.4" analysis: tests: override: From 3be217b053066a6a69a94b95963554d9fe0dcbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 27 Oct 2020 17:42:54 +0100 Subject: [PATCH 11/12] Trying to enable Travis PHP 7.3 again --- .travis.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d1c08a..a8aa171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php php: - #- 7.3 + - 7.3 - 7.4 before_script: - composer self-update --2 diff --git a/composer.json b/composer.json index 0150fa6..a059c76 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "phpunit/phpunit": "^8.5.8", "squizlabs/php_codesniffer": "^2.9.2", "couscous/couscous": "^1.8", - "infection/infection": "^0.18.2" + "infection/infection": "^0.17.7 || ^1.18.2" }, "autoload": { "psr-4": { From 50835d53b242cb649e07e8b2126842f4726af5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 27 Oct 2020 17:54:05 +0100 Subject: [PATCH 12/12] Trying to set PHP version in Scrutinizer --- .scrutinizer.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index f04bd4b..c9de6d6 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -2,14 +2,13 @@ checks: php: true build: + environment: + php: 7.4 nodes: my-tests: dependencies: before: - cd tests && ./run.sh - environment: - php: - version: "7.4" analysis: tests: override: