diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..c9de6d6 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,21 @@ +checks: + php: true + +build: + environment: + php: 7.4 + nodes: + my-tests: + dependencies: + before: + - cd tests && ./run.sh + analysis: + tests: + override: + - php-scrutinizer-run + +filter: + paths: + - "src/*" + - "tests/*" + diff --git a/.travis.yml b/.travis.yml index f331730..a8aa171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,9 @@ language: php php: - - 7.0 - - 7.1 - - 7.2 + - 7.3 + - 7.4 before_script: -- composer self-update +- composer self-update --2 - composer clear-cache - composer update env: @@ -18,7 +17,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 2e8081f..a059c76 100644 --- a/composer.json +++ b/composer.json @@ -13,26 +13,32 @@ } ], "require": { - "php": ">=7.0.0", - "composer-plugin-api": "^1.0" + "php": ">=7.2", + "composer-plugin-api": "^1.0 || ^2.0" }, "require-dev": { - "composer/composer": "^1.0", - "satooshi/php-coveralls": "^1.0", - "phpunit/phpunit": "~5.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.17.7 || ^1.18.2" }, "autoload": { "psr-4": { "TheCodingMachine\\Discovery\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "TheCodingMachine\\Discovery\\Tests\\": "tests/unitTests" + } + }, "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/src/DiscoveryPlugin.php b/src/DiscoveryPlugin.php index bffc06b..35269e5 100644 --- a/src/DiscoveryPlugin.php +++ b/src/DiscoveryPlugin.php @@ -94,4 +94,20 @@ public function getCapabilities() CommandProvider::class => DiscoveryCommandProvider::class, ]; } + + /** + * @inheritDoc + */ + public function deactivate(Composer $composer, IOInterface $io) + { + + } + + /** + * @inheritDoc + */ + public function uninstall(Composer $composer, IOInterface $io) + { + + } } 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 diff --git a/tests/unitTests/AbstractDiscoveryTest.php b/tests/unitTests/AbstractDiscoveryTest.php index 0758004..489c5f5 100644 --- a/tests/unitTests/AbstractDiscoveryTest.php +++ b/tests/unitTests/AbstractDiscoveryTest.php @@ -1,7 +1,7 @@ method('getInstallPath') - ->willReturn($installPath ?? 'tests/fixtures/package_a'); + ->willReturn(realpath($installPath ?? 'tests/fixtures/package_a')); return $installationManager; } diff --git a/tests/unitTests/AssetOperationTest.php b/tests/unitTests/AssetOperationTest.php index 9209c12..4c5fc7d 100644 --- a/tests/unitTests/AssetOperationTest.php +++ b/tests/unitTests/AssetOperationTest.php @@ -1,11 +1,15 @@ 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/CommandProviderTest.php b/tests/unitTests/Commands/CommandProviderTest.php index 8985c00..518c59a 100644 --- a/tests/unitTests/Commands/CommandProviderTest.php +++ b/tests/unitTests/Commands/CommandProviderTest.php @@ -1,12 +1,14 @@ 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 1619087..046c80f 100644 --- a/tests/unitTests/Commands/ListAssetTypesCommandTest.php +++ b/tests/unitTests/Commands/ListAssetTypesCommandTest.php @@ -1,19 +1,15 @@ 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() @@ -42,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() @@ -63,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 12e807b..e6b7d85 100644 --- a/tests/unitTests/Commands/RemoveAssetCommandTest.php +++ b/tests/unitTests/Commands/RemoveAssetCommandTest.php @@ -1,19 +1,15 @@ 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/DiscoveryFileLoaderTest.php b/tests/unitTests/DiscoveryFileLoaderTest.php index 9cd7143..0832f05 100644 --- a/tests/unitTests/DiscoveryFileLoaderTest.php +++ b/tests/unitTests/DiscoveryFileLoaderTest.php @@ -3,10 +3,11 @@ namespace TheCodingMachine\Discovery; +use PHPUnit\Framework\TestCase; use TheCodingMachine\Discovery\Utils\IOException; use TheCodingMachine\Discovery\Utils\JsonException; -class DiscoveryFileLoaderTest extends \PHPUnit_Framework_TestCase +class DiscoveryFileLoaderTest extends TestCase { public function testLoad() { diff --git a/tests/unitTests/DiscoveryTest.php b/tests/unitTests/DiscoveryTest.php index 22fd697..20736ea 100644 --- a/tests/unitTests/DiscoveryTest.php +++ b/tests/unitTests/DiscoveryTest.php @@ -3,9 +3,11 @@ namespace TheCodingMachine\Discovery; -class DiscoveryTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class DiscoveryTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); // Let's load the autogenerated class for the unit tests. @@ -37,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() diff --git a/tests/unitTests/DumperTest.php b/tests/unitTests/DumperTest.php index f24d277..c659228 100644 --- a/tests/unitTests/DumperTest.php +++ b/tests/unitTests/DumperTest.php @@ -1,9 +1,11 @@ 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]);