diff --git a/composer.json b/composer.json index 865413970..3513b8c58 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "composer/ca-bundle": "^1.0", "composer/class-map-generator": "^1.0", "composer/metadata-minifier": "^1.0", - "composer/semver": "^3.2.5", + "composer/semver": "^3.3", "composer/spdx-licenses": "^1.5.7", "composer/xdebug-handler": "^2.0.2 || ^3.0.3", "justinrainbow/json-schema": "^5.2.11", diff --git a/composer.lock b/composer.lock index 02c5ee3b6..9dc770cf1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "213c5ab8912ca04b1f7a77c008875ccc", + "content-hash": "9cc98d4fd8dcc30565a6570841b7ec85", "packages": [ { "name": "composer/ca-bundle", diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index d207f39d1..d3122d737 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -4018,11 +4018,6 @@ parameters: count: 1 path: ../src/Composer/Util/Http/CurlDownloader.php - - - message: "#^Only booleans are allowed in &&, int\\<0, 65536\\> given on the right side\\.$#" - count: 1 - path: ../src/Composer/Util/Http/CurlDownloader.php - - message: "#^Only booleans are allowed in a negated boolean, string given\\.$#" count: 1 @@ -4758,11 +4753,6 @@ parameters: count: 1 path: ../tests/Composer/Test/AllFunctionalTest.php - - - message: "#^Dynamic call to static method Composer\\\\Test\\\\Autoload\\\\AutoloadGeneratorTest\\:\\:assertFileContentEquals\\(\\)\\.$#" - count: 28 - path: ../tests/Composer/Test/Autoload/AutoloadGeneratorTest.php - - message: "#^Dynamic call to static method Composer\\\\Test\\\\TestCase\\:\\:ensureDirectoryExistsAndClear\\(\\)\\.$#" count: 1 @@ -4941,16 +4931,6 @@ parameters: count: 3 path: ../tests/Composer/Test/Installer/BinaryInstallerTest.php - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Composer' and Composer\\\\Composer will always evaluate to true\\.$#" - count: 1 - path: ../tests/Composer/Test/Installer/InstallerEventTest.php - - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\IO…' and Composer\\\\IO\\\\IOInterface will always evaluate to true\\.$#" - count: 1 - path: ../tests/Composer/Test/Installer/InstallerEventTest.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 9 @@ -5021,11 +5001,6 @@ parameters: count: 1 path: ../tests/Composer/Test/Json/JsonManipulatorTest.php - - - message: "#^Parameter \\#1 \\$expectedJson of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertJsonStringEqualsJsonString\\(\\) expects string, string\\|false given\\.$#" - count: 1 - path: ../tests/Composer/Test/Json/JsonManipulatorTest.php - - message: "#^Offset 'ask' might not exist on array\\{ask\\: string, reply\\?\\: string\\}\\|array\\{auth\\: array\\{string, string, string\\|null\\}\\}\\|array\\{text\\: string, verbosity\\?\\: 1\\|2\\|4\\|8\\|16\\}\\.$#" count: 2 @@ -5091,11 +5066,6 @@ parameters: count: 1 path: ../tests/Composer/Test/Package/Dumper/ArrayDumperTest.php - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with true will always evaluate to true\\.$#" - count: 1 - path: ../tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php - - message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#" count: 1 @@ -5156,11 +5126,6 @@ parameters: count: 1 path: ../tests/Composer/Test/Repository/PathRepositoryTest.php - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Repository…' and Composer\\\\Repository\\\\RepositoryInterface will always evaluate to true\\.$#" - count: 1 - path: ../tests/Composer/Test/Repository/RepositoryManagerTest.php - - message: "#^Parameter \\#1 \\$objectOrValue of method ReflectionProperty\\:\\:setValue\\(\\) expects object\\|null, object\\|string given\\.$#" count: 1 @@ -5231,31 +5196,16 @@ parameters: count: 2 path: ../tests/Composer/Test/Util/PerforceTest.php - - - message: "#^Parameter \\#2 \\$string of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringStartsWith\\(\\) expects string, string\\|false given\\.$#" - count: 2 - path: ../tests/Composer/Test/Util/PerforceTest.php - - message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" count: 1 path: ../tests/Composer/Test/Util/PlatformTest.php - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotNull\\(\\) with string will always evaluate to true\\.$#" - count: 1 - path: ../tests/Composer/Test/Util/ProcessExecutorTest.php - - message: "#^Dynamic call to static method Composer\\\\Util\\\\ProcessExecutor\\:\\:getTimeout\\(\\)\\.$#" count: 1 path: ../tests/Composer/Test/Util/ProcessExecutorTest.php - - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with true and 'callbackGet must…' will always evaluate to true\\.$#" - count: 1 - path: ../tests/Composer/Test/Util/RemoteFilesystemTest.php - - message: "#^Parameter \\#1 \\$object of method ReflectionProperty\\:\\:getValue\\(\\) expects object, object\\|string given\\.$#" count: 1 @@ -5271,16 +5221,6 @@ parameters: count: 2 path: ../tests/Composer/Test/Util/RemoteFilesystemTest.php - - - message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, bool\\|string given\\.$#" - count: 1 - path: ../tests/Composer/Test/Util/RemoteFilesystemTest.php - - - - message: "#^Parameter \\#2 \\$haystack of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, string\\|false given\\.$#" - count: 2 - path: ../tests/Composer/Test/Util/RemoteFilesystemTest.php - - message: "#^Implicit array creation is not allowed \\- variable \\$certificate does not exist\\.$#" count: 2 diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 856d441e0..c0d2ddb2e 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -538,10 +538,7 @@ class Installer return $exitCode; } - // exists as of composer/semver 3.3.0 - if (method_exists('Composer\Semver\CompilingMatcher', 'clear')) { // @phpstan-ignore function.alreadyNarrowedType - \Composer\Semver\CompilingMatcher::clear(); - } + \Composer\Semver\CompilingMatcher::clear(); // write lock $platformReqs = $this->extractPlatformRequirements($this->package->getRequires()); diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 47874f829..529279b1f 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -432,8 +432,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $uniques = []; foreach ($names as $name) { - // @phpstan-ignore argument.type - $uniques[substr($name, 0, strpos($name, '/'))] = true; + $uniques[explode('/', $name, 2)[0]] = true; } $vendors = array_keys($uniques); diff --git a/src/Composer/Util/Http/CurlDownloader.php b/src/Composer/Util/Http/CurlDownloader.php index 33753dba9..8e755551a 100644 --- a/src/Composer/Util/Http/CurlDownloader.php +++ b/src/Composer/Util/Http/CurlDownloader.php @@ -176,12 +176,13 @@ class CurlDownloader } $errorMessage = ''; - // @phpstan-ignore argument.type - set_error_handler(static function ($code, $msg) use (&$errorMessage): void { + set_error_handler(static function (int $code, string $msg) use (&$errorMessage): bool { if ($errorMessage) { $errorMessage .= "\n"; } $errorMessage .= Preg::replace('{^fopen\(.*?\): }', '', $msg); + + return true; }); $bodyHandle = fopen($bodyTarget, 'w+b'); restore_error_handler(); diff --git a/src/Composer/Util/Http/Response.php b/src/Composer/Util/Http/Response.php index 0821e054a..e355f256a 100644 --- a/src/Composer/Util/Http/Response.php +++ b/src/Composer/Util/Http/Response.php @@ -101,8 +101,7 @@ class Response */ public function collect(): void { - /** @phpstan-ignore assign.propertyType, assign.propertyType, assign.propertyType */ - $this->request = $this->code = $this->headers = $this->body = null; + unset($this->request, $this->code, $this->headers, $this->body); } /** diff --git a/tests/Composer/Test/Advisory/AuditorTest.php b/tests/Composer/Test/Advisory/AuditorTest.php index 748f6a5f8..5e66951a0 100644 --- a/tests/Composer/Test/Advisory/AuditorTest.php +++ b/tests/Composer/Test/Advisory/AuditorTest.php @@ -158,8 +158,8 @@ Found 2 abandoned packages: } $auditor = new Auditor(); $result = $auditor->audit($io = new BufferIO(), $this->getRepoSet(), $data['packages'], $data['format'] ?? Auditor::FORMAT_PLAIN, $data['warningOnly'], [], $data['abandoned'] ?? Auditor::ABANDONED_IGNORE); - $this->assertSame($expected, $result); - $this->assertSame($output, trim(str_replace("\r", '', $io->getOutput()))); + self::assertSame($expected, $result); + self::assertSame($output, trim(str_replace("\r", '', $io->getOutput()))); } public function ignoredIdsProvider(): \Generator { @@ -311,7 +311,7 @@ Found 2 abandoned packages: $auditor = new Auditor(); $result = $auditor->audit($io = $this->getIOMock(), $this->getRepoSet(), $packages, Auditor::FORMAT_PLAIN, false, $ignoredIds); $io->expects($expectedOutput, true); - $this->assertSame($exitCode, $result); + self::assertSame($exitCode, $result); } private function getRepoSet(): RepositorySet diff --git a/tests/Composer/Test/AllFunctionalTest.php b/tests/Composer/Test/AllFunctionalTest.php index 7fb22795d..452862273 100644 --- a/tests/Composer/Test/AllFunctionalTest.php +++ b/tests/Composer/Test/AllFunctionalTest.php @@ -93,7 +93,7 @@ class AllFunctionalTest extends TestCase $this->fail($proc->getOutput()); } - $this->assertFileExists(self::$pharPath); + self::assertFileExists(self::$pharPath); copy(self::$pharPath, __DIR__.'/../../composer-test.phar'); } @@ -164,16 +164,16 @@ class AllFunctionalTest extends TestCase } } if (isset($testData['EXPECT-REGEX'])) { - $this->assertMatchesRegularExpression($testData['EXPECT-REGEX'], $this->cleanOutput($output)); + self::assertMatchesRegularExpression($testData['EXPECT-REGEX'], $this->cleanOutput($output)); } if (isset($testData['EXPECT-REGEXES'])) { $cleanOutput = $this->cleanOutput($output); foreach (explode("\n", $testData['EXPECT-REGEXES']) as $regex) { - $this->assertMatchesRegularExpression($regex, $cleanOutput, 'Output: '.$output); + self::assertMatchesRegularExpression($regex, $cleanOutput, 'Output: '.$output); } } if (isset($testData['EXPECT-EXIT-CODE'])) { - $this->assertSame($testData['EXPECT-EXIT-CODE'], $exitCode); + self::assertSame($testData['EXPECT-EXIT-CODE'], $exitCode); } } diff --git a/tests/Composer/Test/ApplicationTest.php b/tests/Composer/Test/ApplicationTest.php index 0cd0d1b38..8e4bce1b5 100644 --- a/tests/Composer/Test/ApplicationTest.php +++ b/tests/Composer/Test/ApplicationTest.php @@ -49,7 +49,7 @@ class ApplicationTest extends TestCase $application->doRun(new ArrayInput(['command' => 'about']), $output); $expectedOutput = sprintf('Warning: This development build of Composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.', $_SERVER['PHP_SELF']).PHP_EOL; - $this->assertStringContainsString($expectedOutput, $output->fetch()); + self::assertStringContainsString($expectedOutput, $output->fetch()); } /** @@ -72,6 +72,6 @@ class ApplicationTest extends TestCase $output = new BufferedOutput(); $application->doRun(new ArrayInput(['command' => 'self-update']), $output); - $this->assertSame('', $output->fetch()); + self::assertSame('', $output->fetch()); } } diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 08d51ac74..67930eabb 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -210,13 +210,13 @@ class AutoloadGeneratorTest extends TestCase $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); // Assert that autoload_namespaces.php was correctly generated. - $this->assertAutoloadFiles('main', $this->vendorDir.'/composer'); + self::assertAutoloadFiles('main', $this->vendorDir.'/composer'); // Assert that autoload_psr4.php was correctly generated. - $this->assertAutoloadFiles('psr4', $this->vendorDir.'/composer', 'psr4'); + self::assertAutoloadFiles('psr4', $this->vendorDir.'/composer', 'psr4'); // Assert that autoload_classmap.php was correctly generated. - $this->assertAutoloadFiles('classmap', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('classmap', $this->vendorDir.'/composer', 'classmap'); } public function testRootPackageDevAutoloading(): void @@ -250,11 +250,11 @@ class AutoloadGeneratorTest extends TestCase $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); // check standard autoload - $this->assertAutoloadFiles('main5', $this->vendorDir.'/composer'); - $this->assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('main5', $this->vendorDir.'/composer'); + self::assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap'); // make sure dev autoload is correctly dumped - $this->assertAutoloadFiles('files2', $this->vendorDir.'/composer', 'files'); + self::assertAutoloadFiles('files2', $this->vendorDir.'/composer', 'files'); } public function testRootPackageDevAutoloadingDisabledByDefault(): void @@ -283,11 +283,11 @@ class AutoloadGeneratorTest extends TestCase $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); // check standard autoload - $this->assertAutoloadFiles('main4', $this->vendorDir.'/composer'); - $this->assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('main4', $this->vendorDir.'/composer'); + self::assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap'); // make sure dev autoload is disabled when dev mode is set to false - $this->assertFalse(is_file($this->vendorDir.'/composer/autoload_files.php')); + self::assertFalse(is_file($this->vendorDir.'/composer/autoload_files.php')); } public function testVendorDirSameAsWorkingDir(): void @@ -316,9 +316,9 @@ class AutoloadGeneratorTest extends TestCase file_put_contents($this->vendorDir.'/composersrc/foo.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_2'); - $this->assertAutoloadFiles('main3', $this->vendorDir.'/composer'); - $this->assertAutoloadFiles('psr4_3', $this->vendorDir.'/composer', 'psr4'); - $this->assertAutoloadFiles('classmap3', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('main3', $this->vendorDir.'/composer'); + self::assertAutoloadFiles('psr4_3', $this->vendorDir.'/composer', 'psr4'); + self::assertAutoloadFiles('classmap3', $this->vendorDir.'/composer', 'classmap'); } public function testRootPackageAutoloadingAlternativeVendorDir(): void @@ -345,9 +345,9 @@ class AutoloadGeneratorTest extends TestCase $this->fs->ensureDirectoryExists($this->workingDir.'/composersrc'); file_put_contents($this->workingDir.'/composersrc/foo.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_3'); - $this->assertAutoloadFiles('main2', $this->vendorDir.'/composer'); - $this->assertAutoloadFiles('psr4_2', $this->vendorDir.'/composer', 'psr4'); - $this->assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('main2', $this->vendorDir.'/composer'); + self::assertAutoloadFiles('psr4_2', $this->vendorDir.'/composer', 'psr4'); + self::assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap'); } public function testRootPackageAutoloadingWithTargetDir(): void @@ -374,11 +374,11 @@ class AutoloadGeneratorTest extends TestCase file_put_contents($this->workingDir.'/bar.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'TargetDir'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_target_dir.php', $this->vendorDir.'/autoload.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_target_dir.php', $this->vendorDir.'/composer/autoload_real.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_target_dir.php', $this->vendorDir.'/composer/autoload_static.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_target_dir.php', $this->vendorDir.'/composer/autoload_files.php'); - $this->assertAutoloadFiles('classmap6', $this->vendorDir.'/composer', 'classmap'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_target_dir.php', $this->vendorDir.'/autoload.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_target_dir.php', $this->vendorDir.'/composer/autoload_real.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_target_dir.php', $this->vendorDir.'/composer/autoload_static.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_target_dir.php', $this->vendorDir.'/composer/autoload_files.php'); + self::assertAutoloadFiles('classmap6', $this->vendorDir.'/composer', 'classmap'); } public function testDuplicateFilesWarning(): void @@ -431,8 +431,8 @@ class AutoloadGeneratorTest extends TestCase $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); - $this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); + self::assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); } public function testVendorsAutoloadingWithMetapackages(): void @@ -465,8 +465,8 @@ class AutoloadGeneratorTest extends TestCase $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/lib'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); - $this->assertAutoloadFiles('vendors_meta', $this->vendorDir.'/composer'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); + self::assertAutoloadFiles('vendors_meta', $this->vendorDir.'/composer'); + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); } public function testNonDevAutoloadExclusionWithRecursion(): void @@ -498,8 +498,8 @@ class AutoloadGeneratorTest extends TestCase $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); - $this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); + self::assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); } public function testNonDevAutoloadShouldIncludeReplacedPackages(): void @@ -527,7 +527,7 @@ class AutoloadGeneratorTest extends TestCase $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_5'); - $this->assertEquals( + self::assertEquals( [ 'B\\C\\C' => $this->vendorDir.'/b/b/src/C/C.php', 'Composer\\InstalledVersions' => $this->vendorDir . '/composer/InstalledVersions.php', @@ -565,8 +565,8 @@ class AutoloadGeneratorTest extends TestCase $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); - $this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); + self::assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); } public function testNonDevAutoloadReplacesNestedRequirements(): void @@ -618,7 +618,7 @@ class AutoloadGeneratorTest extends TestCase $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); - $this->assertAutoloadFiles('classmap9', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('classmap9', $this->vendorDir.'/composer', 'classmap'); } public function testPharAutoload(): void @@ -657,9 +657,9 @@ class AutoloadGeneratorTest extends TestCase $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, 'Phar'); - $this->assertAutoloadFiles('phar', $this->vendorDir . '/composer'); - $this->assertAutoloadFiles('phar_psr4', $this->vendorDir . '/composer', 'psr4'); - $this->assertAutoloadFiles('phar_static', $this->vendorDir . '/composer', 'static'); + self::assertAutoloadFiles('phar', $this->vendorDir . '/composer'); + self::assertAutoloadFiles('phar_psr4', $this->vendorDir . '/composer', 'psr4'); + self::assertAutoloadFiles('phar_static', $this->vendorDir . '/composer', 'static'); } public function testPSRToClassMapIgnoresNonExistingDir(): void @@ -676,8 +676,8 @@ class AutoloadGeneratorTest extends TestCase ->will($this->returnValue([])); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); - $this->assertEquals( + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); + self::assertEquals( [ 'Composer\\InstalledVersions' => $this->vendorDir.'/composer/InstalledVersions.php', ], @@ -706,7 +706,7 @@ class AutoloadGeneratorTest extends TestCase file_put_contents($this->workingDir.'/psr4/badfile.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); $expectedClassmap = <<assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); } public function testVendorsClassMapAutoloading(): void @@ -753,8 +753,8 @@ EOF; file_put_contents($this->vendorDir.'/b/b/lib/c.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); - $this->assertEquals( + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); + self::assertEquals( [ 'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php', 'ClassMapBaz' => $this->vendorDir.'/b/b/lib/c.php', @@ -763,7 +763,7 @@ EOF; ], include $this->vendorDir.'/composer/autoload_classmap.php' ); - $this->assertAutoloadFiles('classmap4', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('classmap4', $this->vendorDir.'/composer', 'classmap'); } public function testVendorsClassMapAutoloadingWithTargetDir(): void @@ -794,8 +794,8 @@ EOF; file_put_contents($this->vendorDir.'/b/b/src/c.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); - $this->assertEquals( + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); + self::assertEquals( [ 'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php', 'ClassMapBaz' => $this->vendorDir.'/b/b/src/c.php', @@ -836,8 +836,8 @@ EOF; file_put_contents($this->vendorDir.'/c/c/foo/test.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); - $this->assertEquals( + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); + self::assertEquals( [ 'ClassMapBar' => $this->vendorDir.'/b/b/test.php', 'ClassMapBaz' => $this->vendorDir.'/c/c/foo/test.php', @@ -846,9 +846,9 @@ EOF; ], include $this->vendorDir.'/composer/autoload_classmap.php' ); - $this->assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap'); - $this->assertStringNotContainsString('$loader->setClassMapAuthoritative(true);', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); - $this->assertStringNotContainsString('$loader->setApcuPrefix(', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + self::assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap'); + self::assertStringNotContainsString('$loader->setClassMapAuthoritative(true);', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + self::assertStringNotContainsString('$loader->setApcuPrefix(', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); } public function testClassMapAutoloadingAuthoritativeAndApcu(): void @@ -884,8 +884,8 @@ EOF; $this->generator->setApcu(true); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); - $this->assertEquals( + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); + self::assertEquals( [ 'ClassMapBar' => $this->vendorDir.'/b/b/ClassMapBar.php', 'ClassMapBaz' => $this->vendorDir.'/c/c/foo/ClassMapBaz.php', @@ -894,10 +894,10 @@ EOF; ], include $this->vendorDir.'/composer/autoload_classmap.php' ); - $this->assertAutoloadFiles('classmap8', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('classmap8', $this->vendorDir.'/composer', 'classmap'); - $this->assertStringContainsString('$loader->setClassMapAuthoritative(true);', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); - $this->assertStringContainsString('$loader->setApcuPrefix(', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + self::assertStringContainsString('$loader->setClassMapAuthoritative(true);', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + self::assertStringContainsString('$loader->setApcuPrefix(', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); } public function testClassMapAutoloadingAuthoritativeAndApcuPrefix(): void @@ -933,8 +933,8 @@ EOF; $this->generator->setApcu(true, 'custom\'Prefix'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); - $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); - $this->assertEquals( + self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); + self::assertEquals( [ 'ClassMapBar' => $this->vendorDir.'/b/b/ClassMapBar.php', 'ClassMapBaz' => $this->vendorDir.'/c/c/foo/ClassMapBaz.php', @@ -943,10 +943,10 @@ EOF; ], include $this->vendorDir.'/composer/autoload_classmap.php' ); - $this->assertAutoloadFiles('classmap8', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('classmap8', $this->vendorDir.'/composer', 'classmap'); - $this->assertStringContainsString('$loader->setClassMapAuthoritative(true);', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); - $this->assertStringContainsString('$loader->setApcuPrefix(\'custom\\\'Prefix\');', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + self::assertStringContainsString('$loader->setClassMapAuthoritative(true);', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + self::assertStringContainsString('$loader->setApcuPrefix(\'custom\\\'Prefix\');', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); } public function testFilesAutoloadGeneration(): void @@ -982,18 +982,18 @@ EOF; file_put_contents($this->workingDir.'/root.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoload'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions.php', $this->vendorDir.'/composer/autoload_real.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_functions.php', $this->vendorDir.'/composer/autoload_static.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_functions.php', $this->vendorDir.'/composer/autoload_files.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions.php', $this->vendorDir.'/composer/autoload_real.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_functions.php', $this->vendorDir.'/composer/autoload_static.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_functions.php', $this->vendorDir.'/composer/autoload_files.php'); $loader = require $this->vendorDir . '/autoload.php'; $loader->unregister(); - $this->assertTrue(function_exists('testFilesAutoloadGeneration1')); - $this->assertTrue(function_exists('testFilesAutoloadGeneration2')); - $this->assertTrue(function_exists('testFilesAutoloadGeneration3')); - $this->assertTrue(function_exists('testFilesAutoloadGeneration4')); - $this->assertTrue(function_exists('testFilesAutoloadGenerationRoot')); + self::assertTrue(function_exists('testFilesAutoloadGeneration1')); + self::assertTrue(function_exists('testFilesAutoloadGeneration2')); + self::assertTrue(function_exists('testFilesAutoloadGeneration3')); + self::assertTrue(function_exists('testFilesAutoloadGeneration4')); + self::assertTrue(function_exists('testFilesAutoloadGenerationRoot')); } public function testFilesAutoloadGenerationRemoveExtraEntitiesFromAutoloadFiles(): void @@ -1047,24 +1047,24 @@ EOF; file_put_contents($this->workingDir.'/root.php', 'generator->dump($this->config, $this->repository, $autoloadPackage, $this->im, 'composer', false, 'FilesAutoload'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions_with_include_paths.php', $this->vendorDir.'/composer/autoload_real.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_functions_with_include_paths.php', $this->vendorDir.'/composer/autoload_static.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_functions.php', $this->vendorDir.'/composer/autoload_files.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/include_paths_functions.php', $this->vendorDir.'/composer/include_paths.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions_with_include_paths.php', $this->vendorDir.'/composer/autoload_real.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_functions_with_include_paths.php', $this->vendorDir.'/composer/autoload_static.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_functions.php', $this->vendorDir.'/composer/autoload_files.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/include_paths_functions.php', $this->vendorDir.'/composer/include_paths.php'); $this->generator->dump($this->config, $this->repository, $autoloadPackage, $this->im, 'composer', false, 'FilesAutoload'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions_with_include_paths.php', $this->vendorDir.'/composer/autoload_real.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_functions_with_removed_extra.php', $this->vendorDir.'/composer/autoload_files.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/include_paths_functions_with_removed_extra.php', $this->vendorDir.'/composer/include_paths.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions_with_include_paths.php', $this->vendorDir.'/composer/autoload_real.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_functions_with_removed_extra.php', $this->vendorDir.'/composer/autoload_files.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/include_paths_functions_with_removed_extra.php', $this->vendorDir.'/composer/include_paths.php'); $this->generator->dump($this->config, $this->repository, $notAutoloadPackage, $this->im, 'composer', false, 'FilesAutoload'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php', $this->vendorDir.'/composer/autoload_real.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_functions_with_removed_include_paths_and_autolad_files.php', $this->vendorDir.'/composer/autoload_static.php'); - $this->assertFileDoesNotExist($this->vendorDir.'/composer/autoload_files.php'); - $this->assertFileDoesNotExist($this->vendorDir.'/composer/include_paths.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php', $this->vendorDir.'/composer/autoload_real.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_functions_with_removed_include_paths_and_autolad_files.php', $this->vendorDir.'/composer/autoload_static.php'); + self::assertFileDoesNotExist($this->vendorDir.'/composer/autoload_files.php'); + self::assertFileDoesNotExist($this->vendorDir.'/composer/include_paths.php'); } public function testFilesAutoloadOrderByDependencies(): void @@ -1124,19 +1124,19 @@ EOF; file_put_contents($this->workingDir . '/root2.php', 'generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoloadOrder'); - $this->assertFileContentEquals(__DIR__ . '/Fixtures/autoload_functions_by_dependency.php', $this->vendorDir . '/autoload.php'); - $this->assertFileContentEquals(__DIR__ . '/Fixtures/autoload_real_files_by_dependency.php', $this->vendorDir . '/composer/autoload_real.php'); - $this->assertFileContentEquals(__DIR__ . '/Fixtures/autoload_static_files_by_dependency.php', $this->vendorDir . '/composer/autoload_static.php'); + self::assertFileContentEquals(__DIR__ . '/Fixtures/autoload_functions_by_dependency.php', $this->vendorDir . '/autoload.php'); + self::assertFileContentEquals(__DIR__ . '/Fixtures/autoload_real_files_by_dependency.php', $this->vendorDir . '/composer/autoload_real.php'); + self::assertFileContentEquals(__DIR__ . '/Fixtures/autoload_static_files_by_dependency.php', $this->vendorDir . '/composer/autoload_static.php'); $loader = require $this->vendorDir . '/autoload.php'; $loader->unregister(); - $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency1')); - $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency2')); - $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency3')); - $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency4')); - $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency5')); - $this->assertTrue(function_exists('testFilesAutoloadOrderByDependencyRoot')); + self::assertTrue(function_exists('testFilesAutoloadOrderByDependency1')); + self::assertTrue(function_exists('testFilesAutoloadOrderByDependency2')); + self::assertTrue(function_exists('testFilesAutoloadOrderByDependency3')); + self::assertTrue(function_exists('testFilesAutoloadOrderByDependency4')); + self::assertTrue(function_exists('testFilesAutoloadOrderByDependency5')); + self::assertTrue(function_exists('testFilesAutoloadOrderByDependencyRoot')); } /** @@ -1235,9 +1235,9 @@ return array( EOF; $this->generator->dump($this->config, $this->repository, $rootPackage, $this->im, 'composer', true, '_9'); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); } public function testIncludePathFileGeneration(): void @@ -1266,8 +1266,8 @@ EOF; $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_10'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/include_paths.php', $this->vendorDir.'/composer/include_paths.php'); - $this->assertEquals( + self::assertFileContentEquals(__DIR__.'/Fixtures/include_paths.php', $this->vendorDir.'/composer/include_paths.php'); + self::assertEquals( [ $this->vendorDir."/a/a/lib", $this->vendorDir."/b/b/library", @@ -1300,7 +1300,7 @@ EOF; $loader = require $this->vendorDir."/autoload.php"; $loader->unregister(); - $this->assertEquals( + self::assertEquals( $this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath, get_include_path() ); @@ -1329,7 +1329,7 @@ EOF; $loader = require $this->vendorDir."/autoload.php"; $loader->unregister(); - $this->assertEquals( + self::assertEquals( $this->workingDir."/lib".PATH_SEPARATOR.$this->workingDir."/src".PATH_SEPARATOR.$this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath, get_include_path() ); @@ -1353,7 +1353,7 @@ EOF; $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_12'); - $this->assertFileDoesNotExist($this->vendorDir."/composer/include_paths.php"); + self::assertFileDoesNotExist($this->vendorDir."/composer/include_paths.php"); } public function testPreAndPostEventsAreDispatchedDuringAutoloadDump(): void @@ -1367,7 +1367,7 @@ EOF; [ScriptEvents::POST_AUTOLOAD_DUMP, false] ]; - $this->assertSame(array_shift($series), [$type, $dev]); + self::assertSame(array_shift($series), [$type, $dev]); return 0; }); @@ -1400,8 +1400,8 @@ EOF; $this->fs->ensureDirectoryExists($this->vendorDir.'/a'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'IncludePath'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_include_path.php', $this->vendorDir.'/composer/autoload_real.php'); - $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_include_path.php', $this->vendorDir.'/composer/autoload_static.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_include_path.php', $this->vendorDir.'/composer/autoload_real.php'); + self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_include_path.php', $this->vendorDir.'/composer/autoload_static.php'); } public function testVendorDirExcludedFromWorkingDir(): void @@ -1511,11 +1511,11 @@ return array( EOF; - $this->assertStringEqualsFile($vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); - $this->assertStringEqualsFile($vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); - $this->assertStringEqualsFile($vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); - $this->assertStringContainsString("\$vendorDir . '/b/b/bootstrap.php',\n", (string) file_get_contents($vendorDir.'/composer/autoload_files.php')); - $this->assertStringContainsString("\$baseDir . '/test.php',\n", (string) file_get_contents($vendorDir.'/composer/autoload_files.php')); + self::assertStringEqualsFile($vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); + self::assertStringEqualsFile($vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); + self::assertStringEqualsFile($vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); + self::assertStringContainsString("\$vendorDir . '/b/b/bootstrap.php',\n", (string) file_get_contents($vendorDir.'/composer/autoload_files.php')); + self::assertStringContainsString("\$baseDir . '/test.php',\n", (string) file_get_contents($vendorDir.'/composer/autoload_files.php')); } public function testUpLevelRelativePaths(): void @@ -1596,10 +1596,10 @@ return array( EOF; - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); - $this->assertStringContainsString("\$baseDir . '/../test.php',\n", (string) file_get_contents($this->vendorDir.'/composer/autoload_files.php')); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); + self::assertStringContainsString("\$baseDir . '/../test.php',\n", (string) file_get_contents($this->vendorDir.'/composer/autoload_files.php')); } public function testAutoloadRulesInPackageThatDoesNotExistOnDisk(): void @@ -1632,7 +1632,7 @@ return array( ); EOF; - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); $dep->setAutoload([ 'psr-4' => ['Acme\Foo\\' => './src-psr4'], @@ -1652,7 +1652,7 @@ return array( ); EOF; - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); $dep->setAutoload([ 'classmap' => ['classmap'], @@ -1660,14 +1660,14 @@ EOF; try { $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_19'); } catch (\RuntimeException $e) { - $this->assertSame('Could not scan for classes inside "'.$this->vendorDir.'/dep/a/classmap" which does not appear to be a file nor a folder', $e->getMessage()); + self::assertSame('Could not scan for classes inside "'.$this->vendorDir.'/dep/a/classmap" which does not appear to be a file nor a folder', $e->getMessage()); } $dep->setAutoload([ 'files' => ['./test.php'], ]); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_19'); - $this->assertStringContainsString("\$vendorDir . '/dep/a/test.php',\n", (string) file_get_contents($this->vendorDir.'/composer/autoload_files.php')); + self::assertStringContainsString("\$vendorDir . '/dep/a/test.php',\n", (string) file_get_contents($this->vendorDir.'/composer/autoload_files.php')); $package->setAutoload([ 'exclude-from-classmap' => ['../excludedroot', 'root/excl'], @@ -1677,7 +1677,7 @@ EOF; ]); $map = $this->generator->buildPackageMap($this->im, $package, [$dep]); $parsed = $this->generator->parseAutoloads($map, $package); - $this->assertSame([ + self::assertSame([ preg_quote(strtr((string) realpath(dirname($this->workingDir)), '\\', '/')).'/excludedroot($|/)', preg_quote(strtr((string) realpath($this->workingDir), '\\', '/')).'/root/excl($|/)', ], $parsed['exclude-from-classmap']); @@ -1746,9 +1746,9 @@ return array( EOF; - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); } public function testVendorSubstringPath(): void @@ -1794,8 +1794,8 @@ return array( EOF; $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'VendorSubstring'); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); - $this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); + self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); } public function testExcludeFromClassmap(): void @@ -1864,7 +1864,7 @@ EOF; $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); // Assert that autoload_classmap.php was correctly generated. - $this->assertAutoloadFiles('classmap', $this->vendorDir.'/composer', 'classmap'); + self::assertAutoloadFiles('classmap', $this->vendorDir.'/composer', 'classmap'); } /** @@ -1896,11 +1896,11 @@ EOF; $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); if (null === $expectedFixture) { - $this->assertFileDoesNotExist($this->vendorDir . '/composer/platform_check.php'); - $this->assertStringNotContainsString("require __DIR__ . '/platform_check.php';", (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + self::assertFileDoesNotExist($this->vendorDir . '/composer/platform_check.php'); + self::assertStringNotContainsString("require __DIR__ . '/platform_check.php';", (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); } else { - $this->assertFileContentEquals(__DIR__ . '/Fixtures/platform/' . $expectedFixture . '.php', $this->vendorDir . '/composer/platform_check.php'); - $this->assertStringContainsString("require __DIR__ . '/platform_check.php';", (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + self::assertFileContentEquals(__DIR__ . '/Fixtures/platform/' . $expectedFixture . '.php', $this->vendorDir . '/composer/platform_check.php'); + self::assertStringContainsString("require __DIR__ . '/platform_check.php';", (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); } } @@ -2025,7 +2025,7 @@ EOF; { $a = __DIR__.'/Fixtures/autoload_'.$name.'.php'; $b = $dir.'/autoload_'.$type.'.php'; - $this->assertFileContentEquals($a, $b); + self::assertFileContentEquals($a, $b); } public static function assertFileContentEquals(string $expected, string $actual, ?string $message = null): void diff --git a/tests/Composer/Test/Autoload/ClassLoaderTest.php b/tests/Composer/Test/Autoload/ClassLoaderTest.php index 96ba28c0c..5d385c4fe 100644 --- a/tests/Composer/Test/Autoload/ClassLoaderTest.php +++ b/tests/Composer/Test/Autoload/ClassLoaderTest.php @@ -34,7 +34,7 @@ class ClassLoaderTest extends TestCase $loader->add('Pearlike_', __DIR__ . '/Fixtures'); $loader->addPsr4('ShinyVendor\\ShinyPackage\\', __DIR__ . '/Fixtures'); $loader->loadClass($class); - $this->assertTrue(class_exists($class, false), "->loadClass() loads '$class'"); + self::assertTrue(class_exists($class, false), "->loadClass() loads '$class'"); } /** @@ -57,7 +57,7 @@ class ClassLoaderTest extends TestCase public function testGetPrefixesWithNoPSR0Configuration(): void { $loader = new ClassLoader(); - $this->assertEmpty($loader->getPrefixes()); + self::assertEmpty($loader->getPrefixes()); } public function testSerializability(): void diff --git a/tests/Composer/Test/CacheTest.php b/tests/Composer/Test/CacheTest.php index 81a07b6d1..e5eb0e252 100644 --- a/tests/Composer/Test/CacheTest.php +++ b/tests/Composer/Test/CacheTest.php @@ -77,9 +77,9 @@ class CacheTest extends TestCase $this->cache->gc(600, 1024 * 1024 * 1024); for ($i = 1; $i < 4; $i++) { - $this->assertFileDoesNotExist("{$this->root}/cached.file{$i}.zip"); + self::assertFileDoesNotExist("{$this->root}/cached.file{$i}.zip"); } - $this->assertFileExists("{$this->root}/cached.file0.zip"); + self::assertFileExists("{$this->root}/cached.file0.zip"); } public function testRemoveFilesWhenCacheIsTooLarge(): void @@ -106,15 +106,15 @@ class CacheTest extends TestCase $this->cache->gc(600, 1500); for ($i = 0; $i < 3; $i++) { - $this->assertFileDoesNotExist("{$this->root}/cached.file{$i}.zip"); + self::assertFileDoesNotExist("{$this->root}/cached.file{$i}.zip"); } - $this->assertFileExists("{$this->root}/cached.file3.zip"); + self::assertFileExists("{$this->root}/cached.file3.zip"); } public function testClearCache(): void { $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $cache = new Cache($io, $this->root, 'a-z0-9.', $this->filesystem); - $this->assertTrue($cache->clear()); + self::assertTrue($cache->clear()); } } diff --git a/tests/Composer/Test/Command/AboutCommandTest.php b/tests/Composer/Test/Command/AboutCommandTest.php index 7701fbfd3..ad560435d 100644 --- a/tests/Composer/Test/Command/AboutCommandTest.php +++ b/tests/Composer/Test/Command/AboutCommandTest.php @@ -12,10 +12,10 @@ class AboutCommandTest extends TestCase { $composerVersion = Composer::getVersion(); $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'about'])); - $this->assertStringContainsString("Composer - Dependency Manager for PHP - version $composerVersion", $appTester->getDisplay()); + self::assertSame(0, $appTester->run(['command' => 'about'])); + self::assertStringContainsString("Composer - Dependency Manager for PHP - version $composerVersion", $appTester->getDisplay()); - $this->assertStringContainsString("Composer is a dependency manager tracking local dependencies of your projects and libraries.", $appTester->getDisplay()); - $this->assertStringContainsString("See https://getcomposer.org/ for more information.", $appTester->getDisplay()); + self::assertStringContainsString("Composer is a dependency manager tracking local dependencies of your projects and libraries.", $appTester->getDisplay()); + self::assertStringContainsString("See https://getcomposer.org/ for more information.", $appTester->getDisplay()); } } diff --git a/tests/Composer/Test/Command/ArchiveCommandTest.php b/tests/Composer/Test/Command/ArchiveCommandTest.php index 1ed93f5fd..be9e8df57 100644 --- a/tests/Composer/Test/Command/ArchiveCommandTest.php +++ b/tests/Composer/Test/Command/ArchiveCommandTest.php @@ -103,7 +103,7 @@ class ArchiveCommandTest extends TestCase null )->willReturn(0); - $this->assertEquals(0, $command->run($input, $output)); + self::assertEquals(0, $command->run($input, $output)); } public function testUsesConfigFromComposerObjectWithPackageName(): void diff --git a/tests/Composer/Test/Command/BaseDependencyCommandTest.php b/tests/Composer/Test/Command/BaseDependencyCommandTest.php index 6442b7f70..c663b70f7 100644 --- a/tests/Composer/Test/Command/BaseDependencyCommandTest.php +++ b/tests/Composer/Test/Command/BaseDependencyCommandTest.php @@ -45,7 +45,7 @@ class BaseDependencyCommandTest extends TestCase $this->expectExceptionMessage($expectedExceptionMessage); $appTester = $this->getApplicationTester(); - $this->assertEquals(Command::FAILURE, $appTester->run(['command' => $command] + $parameters)); + self::assertEquals(Command::FAILURE, $appTester->run(['command' => $command] + $parameters)); } /** @@ -97,7 +97,7 @@ class BaseDependencyCommandTest extends TestCase $this->expectExceptionMessage('A valid composer.lock file is required to run this command with --locked'); $appTester = $this->getApplicationTester(); - $this->assertEquals( + self::assertEquals( Command::FAILURE, $appTester->run(['command' => $command] + $parameters + ['--locked' => true] ) @@ -125,7 +125,7 @@ class BaseDependencyCommandTest extends TestCase $this->expectExceptionMessage(sprintf('Could not find package "%s" in your project', $packageToBeInspected)); $appTester = $this->getApplicationTester(); - $this->assertEquals( + self::assertEquals( Command::FAILURE, $appTester->run(['command' => $command] + $parameters) ); @@ -164,7 +164,7 @@ class BaseDependencyCommandTest extends TestCase $appTester = $this->getApplicationTester(); - $this->assertEquals(Command::FAILURE, $appTester->run(['command' => $command] + $parameters)); + self::assertEquals(Command::FAILURE, $appTester->run(['command' => $command] + $parameters)); } /** @@ -199,7 +199,7 @@ class BaseDependencyCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(['command' => $command] + $parameters); - $this->assertSame($expectedWarningMessage, trim($appTester->getDisplay(true))); + self::assertSame($expectedWarningMessage, trim($appTester->getDisplay(true))); } /** @@ -296,7 +296,7 @@ class BaseDependencyCommandTest extends TestCase self::assertSame($expectedStatusCode, $appTester->getStatusCode()); - $this->assertEquals(trim($expectedOutput), $this->trimLines($appTester->getDisplay(true))); + self::assertEquals(trim($expectedOutput), $this->trimLines($appTester->getDisplay(true))); } /** @@ -420,7 +420,7 @@ OUTPUT ]); self::assertSame($expectedStatusCode, $appTester->getStatusCode()); - $this->assertSame(trim($expectedOutput), $this->trimLines($appTester->getDisplay(true))); + self::assertSame(trim($expectedOutput), $this->trimLines($appTester->getDisplay(true))); } /** diff --git a/tests/Composer/Test/Command/BumpCommandTest.php b/tests/Composer/Test/Command/BumpCommandTest.php index 383aaf90c..8e8161dcf 100644 --- a/tests/Composer/Test/Command/BumpCommandTest.php +++ b/tests/Composer/Test/Command/BumpCommandTest.php @@ -41,10 +41,10 @@ class BumpCommandTest extends TestCase } $appTester = $this->getApplicationTester(); - $this->assertSame($exitCode, $appTester->run(array_merge(['command' => 'bump'], $command))); + self::assertSame($exitCode, $appTester->run(array_merge(['command' => 'bump'], $command))); $json = new JsonFile('./composer.json'); - $this->assertSame($expected, $json->read()); + self::assertSame($expected, $json->read()); } public function testBumpFailsOnNonExistingComposerFile(): void @@ -54,9 +54,9 @@ class BumpCommandTest extends TestCase unlink($composerJsonPath); $appTester = $this->getApplicationTester(); - $this->assertSame(1, $appTester->run(['command' => 'bump'], ['capture_stderr_separately' => true])); + self::assertSame(1, $appTester->run(['command' => 'bump'], ['capture_stderr_separately' => true])); - $this->assertStringContainsString("./composer.json is not readable.", $appTester->getErrorOutput()); + self::assertStringContainsString("./composer.json is not readable.", $appTester->getErrorOutput()); } public function testBumpFailsOnWriteErrorToComposerFile(): void @@ -66,9 +66,9 @@ class BumpCommandTest extends TestCase chmod($composerJsonPath, 0444); $appTester = $this->getApplicationTester(); - $this->assertSame(1, $appTester->run(['command' => 'bump'], ['capture_stderr_separately' => true])); + self::assertSame(1, $appTester->run(['command' => 'bump'], ['capture_stderr_separately' => true])); - $this->assertStringContainsString("./composer.json is not writable.", $appTester->getErrorOutput()); + self::assertStringContainsString("./composer.json is not writable.", $appTester->getErrorOutput()); } public static function provideTests(): \Generator diff --git a/tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php b/tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php index 9f9d56df6..27d852697 100644 --- a/tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php +++ b/tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php @@ -47,7 +47,7 @@ class CheckPlatformReqsCommandTest extends TestCase $appTester->run(array_merge(['command' => 'check-platform-reqs'], $command)); $appTester->assertCommandIsSuccessful(); - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + self::assertSame(trim($expected), trim($appTester->getDisplay(true))); } public function testExceptionThrownIfNoLockfileFound(): void @@ -89,7 +89,7 @@ ext-foobar 2.3.4 success' ]; } - public function testFailedPlatformRequirement(): void + public function testFailedPlatformRequirement(): void { $this->initTempComposer([ 'require' => [ @@ -137,6 +137,6 @@ ext-foobar 2.3.4 success' } ]'; - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + self::assertSame(trim($expected), trim($appTester->getDisplay(true))); } } diff --git a/tests/Composer/Test/Command/ClearCacheCommandTest.php b/tests/Composer/Test/Command/ClearCacheCommandTest.php index 7a528ffae..b76414423 100644 --- a/tests/Composer/Test/Command/ClearCacheCommandTest.php +++ b/tests/Composer/Test/Command/ClearCacheCommandTest.php @@ -32,7 +32,7 @@ class ClearCacheCommandTest extends TestCase $output = $appTester->getDisplay(true); - $this->assertStringContainsString('All caches cleared.', $output); + self::assertStringContainsString('All caches cleared.', $output); } public function testClearCacheCommandWithOptionGarbageCollection(): void @@ -44,7 +44,7 @@ class ClearCacheCommandTest extends TestCase $output = $appTester->getDisplay(true); - $this->assertStringContainsString('All caches garbage-collected.', $output); + self::assertStringContainsString('All caches garbage-collected.', $output); } public function testClearCacheCommandWithOptionNoCache(): void @@ -56,6 +56,6 @@ class ClearCacheCommandTest extends TestCase $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Cache is not enabled', $output); + self::assertStringContainsString('Cache is not enabled', $output); } } diff --git a/tests/Composer/Test/Command/ConfigCommandTest.php b/tests/Composer/Test/Command/ConfigCommandTest.php index 9d08f7cc5..5542eb828 100644 --- a/tests/Composer/Test/Command/ConfigCommandTest.php +++ b/tests/Composer/Test/Command/ConfigCommandTest.php @@ -32,7 +32,7 @@ class ConfigCommandTest extends TestCase $appTester->assertCommandIsSuccessful($appTester->getDisplay()); - $this->assertSame($expected, json_decode((string) file_get_contents('composer.json'), true)); + self::assertSame($expected, json_decode((string) file_get_contents('composer.json'), true)); } public static function provideConfigUpdates(): \Generator @@ -133,8 +133,8 @@ class ConfigCommandTest extends TestCase $appTester->assertCommandIsSuccessful(); - $this->assertSame($expected, trim($appTester->getDisplay(true))); - $this->assertSame($composerJson, json_decode((string) file_get_contents('composer.json'), true), 'The composer.json should not be modified by config reads'); + self::assertSame($expected, trim($appTester->getDisplay(true))); + self::assertSame($composerJson, json_decode((string) file_get_contents('composer.json'), true), 'The composer.json should not be modified by config reads'); } public static function provideConfigReads(): \Generator diff --git a/tests/Composer/Test/Command/DiagnoseCommandTest.php b/tests/Composer/Test/Command/DiagnoseCommandTest.php index 5ca670265..28ef18f50 100644 --- a/tests/Composer/Test/Command/DiagnoseCommandTest.php +++ b/tests/Composer/Test/Command/DiagnoseCommandTest.php @@ -23,13 +23,13 @@ class DiagnoseCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(['command' => 'diagnose']); - $this->assertSame(1, $appTester->getStatusCode()); + self::assertSame(1, $appTester->getStatusCode()); $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Checking composer.json: WARNING + self::assertStringContainsString('Checking composer.json: WARNING No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.', $output); - $this->assertStringContainsString('Checking http connectivity to packagist: OK + self::assertStringContainsString('Checking http connectivity to packagist: OK Checking https connectivity to packagist: OK Checking github.com rate limit: ', $output); } @@ -44,9 +44,9 @@ Checking github.com rate limit: ', $output); $appTester->assertCommandIsSuccessful(); $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Checking composer.json: OK', $output); + self::assertStringContainsString('Checking composer.json: OK', $output); - $this->assertStringContainsString('Checking http connectivity to packagist: OK + self::assertStringContainsString('Checking http connectivity to packagist: OK Checking https connectivity to packagist: OK Checking github.com rate limit: ', $output); } diff --git a/tests/Composer/Test/Command/DumpAutoloadCommandTest.php b/tests/Composer/Test/Command/DumpAutoloadCommandTest.php index 88d128772..fd58156ab 100644 --- a/tests/Composer/Test/Command/DumpAutoloadCommandTest.php +++ b/tests/Composer/Test/Command/DumpAutoloadCommandTest.php @@ -10,41 +10,41 @@ class DumpAutoloadCommandTest extends TestCase public function testDumpAutoload(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload'])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload'])); $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Generating autoload files', $output); - $this->assertStringContainsString('Generated autoload files', $output); + self::assertStringContainsString('Generating autoload files', $output); + self::assertStringContainsString('Generated autoload files', $output); } public function testDumpDevAutoload(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload', '--dev' => true])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload', '--dev' => true])); $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Generating autoload files', $output); - $this->assertStringContainsString('Generated autoload files', $output); + self::assertStringContainsString('Generating autoload files', $output); + self::assertStringContainsString('Generated autoload files', $output); } public function testDumpNoDevAutoload(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload', '--dev' => true])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload', '--dev' => true])); $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Generating autoload files', $output); - $this->assertStringContainsString('Generated autoload files', $output); + self::assertStringContainsString('Generating autoload files', $output); + self::assertStringContainsString('Generated autoload files', $output); } public function testUsingOptimizeAndStrictPsr(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload', '--optimize' => true, '--strict-psr' => true])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload', '--optimize' => true, '--strict-psr' => true])); $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Generating optimized autoload files', $output); - $this->assertMatchesRegularExpression('/Generated optimized autoload files containing \d+ classes/', $output); + self::assertStringContainsString('Generating optimized autoload files', $output); + self::assertMatchesRegularExpression('/Generated optimized autoload files containing \d+ classes/', $output); } public function testFailsUsingStrictPsrIfClassMapViolationsAreFound(): void @@ -59,30 +59,30 @@ class DumpAutoloadCommandTest extends TestCase mkdir($dir . '/src/'); file_put_contents($dir . '/src/Foo.php', 'getApplicationTester(); - $this->assertSame(1, $appTester->run(['command' => 'dump-autoload', '--optimize' => true, '--strict-psr' => true])); + self::assertSame(1, $appTester->run(['command' => 'dump-autoload', '--optimize' => true, '--strict-psr' => true])); $output = $appTester->getDisplay(true); - $this->assertMatchesRegularExpression('/Class Application\\\Src\\\Foo located in .*? does not comply with psr-4 autoloading standard. Skipping./', $output); + self::assertMatchesRegularExpression('/Class Application\\\Src\\\Foo located in .*? does not comply with psr-4 autoloading standard. Skipping./', $output); } public function testUsingClassmapAuthoritative(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload', '--classmap-authoritative' => true])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload', '--classmap-authoritative' => true])); $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Generating optimized autoload files (authoritative)', $output); - $this->assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output); + self::assertStringContainsString('Generating optimized autoload files (authoritative)', $output); + self::assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output); } public function testUsingClassmapAuthoritativeAndStrictPsr(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload', '--classmap-authoritative' => true, '--strict-psr' => true])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload', '--classmap-authoritative' => true, '--strict-psr' => true])); $output = $appTester->getDisplay(true); - $this->assertStringContainsString('Generating optimized autoload files', $output); - $this->assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output); + self::assertStringContainsString('Generating optimized autoload files', $output); + self::assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output); } public function testStrictPsrDoesNotWorkWithoutOptimizedAutoloader(): void @@ -112,7 +112,7 @@ class DumpAutoloadCommandTest extends TestCase ]); $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload'])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload'])); self::assertStringContainsString('ComposerAutoloaderInitFoobar', (string) file_get_contents($dir . '/vendor/autoload.php')); } @@ -147,7 +147,7 @@ class DumpAutoloadCommandTest extends TestCase ); $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload'])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload'])); self::assertStringContainsString('ComposerAutoloaderInitFoobar', (string) file_get_contents($dir . '/vendor/autoload.php')); } @@ -180,7 +180,7 @@ class DumpAutoloadCommandTest extends TestCase ); $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'dump-autoload'])); + self::assertSame(0, $appTester->run(['command' => 'dump-autoload'])); self::assertStringContainsString('ComposerAutoloaderInit2d4a6be9a93712c5d6a119b26734a047', (string) file_get_contents($dir . '/vendor/autoload.php')); } diff --git a/tests/Composer/Test/Command/ExecCommandTest.php b/tests/Composer/Test/Command/ExecCommandTest.php index ee195c4b5..102122b64 100644 --- a/tests/Composer/Test/Command/ExecCommandTest.php +++ b/tests/Composer/Test/Command/ExecCommandTest.php @@ -49,7 +49,7 @@ class ExecCommandTest extends TestCase $output = $appTester->getDisplay(true); - $this->assertSame( + self::assertSame( 'Available binaries: - b - c diff --git a/tests/Composer/Test/Command/FundCommandTest.php b/tests/Composer/Test/Command/FundCommandTest.php index b1563b8ad..45e31fb14 100644 --- a/tests/Composer/Test/Command/FundCommandTest.php +++ b/tests/Composer/Test/Command/FundCommandTest.php @@ -56,7 +56,7 @@ class FundCommandTest extends TestCase $appTester->run(array_merge(['command' => 'fund'], $command)); $appTester->assertCommandIsSuccessful(); - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + self::assertSame(trim($expected), trim($appTester->getDisplay(true))); } public static function useCaseProvider(): Generator diff --git a/tests/Composer/Test/Command/HomeCommandTest.php b/tests/Composer/Test/Command/HomeCommandTest.php index fd37e2f89..d0b722ec2 100644 --- a/tests/Composer/Test/Command/HomeCommandTest.php +++ b/tests/Composer/Test/Command/HomeCommandTest.php @@ -54,7 +54,7 @@ class HomeCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(array_merge(['command' => 'home', '--show' => true], $command)); - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + self::assertSame(trim($expected), trim($appTester->getDisplay(true))); } public static function useCaseProvider(): Generator diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php index 6030868ef..18847c1e4 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -23,24 +23,24 @@ class InitCommandTest extends TestCase { $command = new InitCommand; $author = $this->callParseAuthorString($command, 'John Smith '); - $this->assertEquals('John Smith', $author['name']); - $this->assertEquals('john@example.com', $author['email']); + self::assertEquals('John Smith', $author['name']); + self::assertEquals('john@example.com', $author['email']); } public function testParseValidAuthorStringWithoutEmail(): void { $command = new InitCommand; $author = $this->callParseAuthorString($command, 'John Smith'); - $this->assertEquals('John Smith', $author['name']); - $this->assertNull($author['email']); + self::assertEquals('John Smith', $author['name']); + self::assertNull($author['email']); } public function testParseValidUtf8AuthorString(): void { $command = new InitCommand; $author = $this->callParseAuthorString($command, 'Matti Meikäläinen '); - $this->assertEquals('Matti Meikäläinen', $author['name']); - $this->assertEquals('matti@example.com', $author['email']); + self::assertEquals('Matti Meikäläinen', $author['name']); + self::assertEquals('matti@example.com', $author['email']); } public function testParseValidUtf8AuthorStringWithNonSpacingMarks(): void @@ -49,16 +49,16 @@ class InitCommandTest extends TestCase $utf8_expected = "Matti Meika\xCC\x88la\xCC\x88inen"; $command = new InitCommand; $author = $this->callParseAuthorString($command, $utf8_expected." "); - $this->assertEquals($utf8_expected, $author['name']); - $this->assertEquals('matti@example.com', $author['email']); + self::assertEquals($utf8_expected, $author['name']); + self::assertEquals('matti@example.com', $author['email']); } public function testParseNumericAuthorString(): void { $command = new InitCommand; $author = $this->callParseAuthorString($command, 'h4x0r '); - $this->assertEquals('h4x0r', $author['name']); - $this->assertEquals('h4x@example.com', $author['email']); + self::assertEquals('h4x0r', $author['name']); + self::assertEquals('h4x@example.com', $author['email']); } /** @@ -72,8 +72,8 @@ class InitCommandTest extends TestCase $command, 'Johnathon "Johnny" Smith ' ); - $this->assertEquals('Johnathon "Johnny" Smith', $author['name']); - $this->assertEquals('john@example.com', $author['email']); + self::assertEquals('Johnathon "Johnny" Smith', $author['name']); + self::assertEquals('john@example.com', $author['email']); } /** @@ -87,8 +87,8 @@ class InitCommandTest extends TestCase $command, 'Johnathon (Johnny) Smith ' ); - $this->assertEquals('Johnathon (Johnny) Smith', $author['name']); - $this->assertEquals('john@example.com', $author['email']); + self::assertEquals('Johnathon (Johnny) Smith', $author['name']); + self::assertEquals('john@example.com', $author['email']); } public function testParseEmptyAuthorString(): void @@ -109,21 +109,21 @@ class InitCommandTest extends TestCase { $command = new InitCommand; $namespace = $command->namespaceFromPackageName('new_projects.acme-extra/package-name'); - $this->assertEquals('NewProjectsAcmeExtra\PackageName', $namespace); + self::assertEquals('NewProjectsAcmeExtra\PackageName', $namespace); } public function testNamespaceFromInvalidPackageName(): void { $command = new InitCommand; $namespace = $command->namespaceFromPackageName('invalid-package-name'); - $this->assertNull($namespace); + self::assertNull($namespace); } public function testNamespaceFromMissingPackageName(): void { $command = new InitCommand; $namespace = $command->namespaceFromPackageName(''); - $this->assertNull($namespace); + self::assertNull($namespace); } /** @@ -168,7 +168,7 @@ class InitCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(['command' => 'init', '--no-interaction' => true, '--name' => 'test/pkg']); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -176,7 +176,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunInvalidAuthorArgumentInvalidEmail(): void @@ -210,7 +210,7 @@ class InitCommandTest extends TestCase '--author' => 'Mr. Test ', ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -224,7 +224,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunAuthorArgumentMissingEmail(): void @@ -241,7 +241,7 @@ class InitCommandTest extends TestCase '--author' => 'Mr. Test', ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -254,7 +254,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunSingleRepositoryArgument(): void @@ -273,7 +273,7 @@ class InitCommandTest extends TestCase ], ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -287,7 +287,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunMultipleRepositoryArguments(): void @@ -308,7 +308,7 @@ class InitCommandTest extends TestCase ], ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -335,7 +335,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunStability(): void @@ -352,7 +352,7 @@ class InitCommandTest extends TestCase '--stability' => 'dev', ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -361,7 +361,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunInvalidStability(): void @@ -378,9 +378,9 @@ class InitCommandTest extends TestCase '--stability' => 'bogus', ], ['capture_stderr_separately' => true]); - $this->assertSame(1, $appTester->getStatusCode()); + self::assertSame(1, $appTester->getStatusCode()); - $this->assertMatchesRegularExpression("/minimum-stability\s+:\s+Does not have a value in the enumeration/", $appTester->getErrorOutput()); + self::assertMatchesRegularExpression("/minimum-stability\s+:\s+Does not have a value in the enumeration/", $appTester->getErrorOutput()); } public function testRunRequireOne(): void @@ -399,7 +399,7 @@ class InitCommandTest extends TestCase ], ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -409,7 +409,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunRequireMultiple(): void @@ -429,7 +429,7 @@ class InitCommandTest extends TestCase ], ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -440,7 +440,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunInvalidRequire(): void @@ -479,7 +479,7 @@ class InitCommandTest extends TestCase ], ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -490,7 +490,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunRequireDevMultiple(): void @@ -510,7 +510,7 @@ class InitCommandTest extends TestCase ], ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -522,7 +522,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunInvalidRequireDev(): void @@ -559,7 +559,7 @@ class InitCommandTest extends TestCase '--autoload' => 'testMapping/' ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -572,7 +572,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunHomepage(): void @@ -589,7 +589,7 @@ class InitCommandTest extends TestCase '--homepage' => 'https://example.org/' ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -598,7 +598,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunInvalidHomepage(): void @@ -615,8 +615,8 @@ class InitCommandTest extends TestCase '--homepage' => 'not-a-url', ], ['capture_stderr_separately' => true]); - $this->assertSame(1, $appTester->getStatusCode()); - $this->assertMatchesRegularExpression("/homepage\s*:\s*Invalid URL format/", $appTester->getErrorOutput()); + self::assertSame(1, $appTester->getStatusCode()); + self::assertMatchesRegularExpression("/homepage\s*:\s*Invalid URL format/", $appTester->getErrorOutput()); } public function testRunDescription(): void @@ -633,7 +633,7 @@ class InitCommandTest extends TestCase '--description' => 'My first example package' ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -642,7 +642,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunType(): void @@ -659,7 +659,7 @@ class InitCommandTest extends TestCase '--type' => 'library' ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -668,7 +668,7 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } public function testRunLicense(): void @@ -685,7 +685,7 @@ class InitCommandTest extends TestCase '--license' => 'MIT' ]); - $this->assertSame(0, $appTester->getStatusCode()); + self::assertSame(0, $appTester->getStatusCode()); $expected = [ 'name' => 'test/pkg', @@ -694,6 +694,6 @@ class InitCommandTest extends TestCase ]; $file = new JsonFile($dir . '/composer.json'); - $this->assertEquals($expected, $file->read()); + self::assertEquals($expected, $file->read()); } } diff --git a/tests/Composer/Test/Command/InstallCommandTest.php b/tests/Composer/Test/Command/InstallCommandTest.php index 8787de889..ebaf15cbe 100644 --- a/tests/Composer/Test/Command/InstallCommandTest.php +++ b/tests/Composer/Test/Command/InstallCommandTest.php @@ -42,7 +42,7 @@ class InstallCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(array_merge(['command' => 'install'], $command)); - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + self::assertSame(trim($expected), trim($appTester->getDisplay(true))); } public function errorCaseProvider(): Generator @@ -118,7 +118,7 @@ OUTPUT $appTester = $this->getApplicationTester(); $appTester->run(['command' => 'install', '--no-progress' => true]); - $this->assertSame('Installing dependencies from lock file (including require-dev) + self::assertSame('Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Package operations: 2 installs, 0 updates, 0 removals - Installing root/another (1.0.0) @@ -148,7 +148,7 @@ Generating autoload files', trim($appTester->getDisplay(true))); $appTester = $this->getApplicationTester(); $appTester->run(['command' => 'install', '--no-progress' => true, '--no-dev' => true]); - $this->assertSame('Installing dependencies from lock file + self::assertSame('Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 1 install, 0 updates, 0 removals - Installing root/req (1.0.0) @@ -175,7 +175,7 @@ Generating autoload files', trim($appTester->getDisplay(true))); $appTester = $this->getApplicationTester(); $appTester->run(['command' => 'install', '--no-progress' => true]); - $this->assertSame('Installing dependencies from lock file (including require-dev) + self::assertSame('Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Package operations: 1 install, 0 updates, 0 removals - Installing root/another (1.0.0) diff --git a/tests/Composer/Test/Command/LicensesCommandTest.php b/tests/Composer/Test/Command/LicensesCommandTest.php index fa92d5496..b7c86bd04 100644 --- a/tests/Composer/Test/Command/LicensesCommandTest.php +++ b/tests/Composer/Test/Command/LicensesCommandTest.php @@ -54,7 +54,7 @@ class LicensesCommandTest extends TestCase public function testBasicRun(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'license'])); + self::assertSame(0, $appTester->run(['command' => 'license'])); $expected = [ ["Name:", "test/pkg"], @@ -81,14 +81,14 @@ class LicensesCommandTest extends TestCase if (!isset($expected[$i])) { $this->fail('Got more output lines than expected'); } - $this->assertMatchesRegularExpression("/" . implode("\s+", $expected[$i]) . "/", $line); + self::assertMatchesRegularExpression("/" . implode("\s+", $expected[$i]) . "/", $line); } } public function testNoDev(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'license', '--no-dev' => true])); + self::assertSame(0, $appTester->run(['command' => 'license', '--no-dev' => true])); $expected = [ ["Name:", "test/pkg"], @@ -114,14 +114,14 @@ class LicensesCommandTest extends TestCase if (!isset($expected[$i])) { $this->fail('Got more output lines than expected'); } - $this->assertMatchesRegularExpression("/" . implode("\s+", $expected[$i]) . "/", $line); + self::assertMatchesRegularExpression("/" . implode("\s+", $expected[$i]) . "/", $line); } } public function testFormatJson(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'license', '--format' => 'json'], ['capture_stderr_separately' => true])); + self::assertSame(0, $appTester->run(['command' => 'license', '--format' => 'json'], ['capture_stderr_separately' => true])); $expected = [ "name" => "test/pkg", @@ -153,13 +153,13 @@ class LicensesCommandTest extends TestCase ] ]; - $this->assertSame($expected, json_decode($appTester->getDisplay(), true)); + self::assertSame($expected, json_decode($appTester->getDisplay(), true)); } public function testFormatSummary(): void { $appTester = $this->getApplicationTester(); - $this->assertSame(0, $appTester->run(['command' => 'license', '--format' => 'summary'])); + self::assertSame(0, $appTester->run(['command' => 'license', '--format' => 'summary'])); $expected = [ ['-', '-'], @@ -176,7 +176,7 @@ class LicensesCommandTest extends TestCase foreach ($expected as $i => $expect) { [$key, $value] = $expect; - $this->assertMatchesRegularExpression("/$key\s+$value/", $lines[$i]); + self::assertMatchesRegularExpression("/$key\s+$value/", $lines[$i]); } } diff --git a/tests/Composer/Test/Command/ReinstallCommandTest.php b/tests/Composer/Test/Command/ReinstallCommandTest.php index c25c00202..1e81a7790 100644 --- a/tests/Composer/Test/Command/ReinstallCommandTest.php +++ b/tests/Composer/Test/Command/ReinstallCommandTest.php @@ -47,10 +47,10 @@ class ReinstallCommandTest extends TestCase 'packages' => $packages ]); - $this->assertSame($expected, trim($appTester->getDisplay(true))); + self::assertSame($expected, trim($appTester->getDisplay(true))); } - public function caseProvider(): Generator + public function caseProvider(): Generator { yield 'reinstall a package' => [ ['root/req', 'root/anotherreq'], diff --git a/tests/Composer/Test/Command/RemoveCommandTest.php b/tests/Composer/Test/Command/RemoveCommandTest.php index f34b0c761..f87199323 100644 --- a/tests/Composer/Test/Command/RemoveCommandTest.php +++ b/tests/Composer/Test/Command/RemoveCommandTest.php @@ -28,7 +28,7 @@ class RemoveCommandTest extends TestCase $this->expectExceptionMessage('Not enough arguments (missing: "packages").'); $appTester = $this->getApplicationTester(); - $this->assertEquals(Command::FAILURE, $appTester->run(['command' => 'remove'])); + self::assertEquals(Command::FAILURE, $appTester->run(['command' => 'remove'])); } public function testExceptionWhenRunningUnusedWithoutLockFile(): void @@ -39,7 +39,7 @@ class RemoveCommandTest extends TestCase $this->expectExceptionMessage('A valid composer.lock file is required to run this command with --unused'); $appTester = $this->getApplicationTester(); - $this->assertEquals(Command::FAILURE, $appTester->run(['command' => 'remove', '--unused' => true])); + self::assertEquals(Command::FAILURE, $appTester->run(['command' => 'remove', '--unused' => true])); } public function testWarningWhenRemovingNonExistentPackage(): void @@ -64,7 +64,7 @@ class RemoveCommandTest extends TestCase self::assertEquals(Command::SUCCESS, $appTester->run(['command' => 'remove', 'packages' => ['root/req'], '--dev' => true, '--no-update' => true, '--no-interaction' => true])); self::assertSame('root/req could not be found in require-dev but it is present in require ./composer.json has been updated', trim($appTester->getDisplay(true))); - $this->assertEquals(['require' => ['root/req' => '1.*']], (new JsonFile('./composer.json'))->read()); + self::assertEquals(['require' => ['root/req' => '1.*']], (new JsonFile('./composer.json'))->read()); } public function testWarningWhenRemovingPackageWithDeprecatedDependenciesFlag(): void @@ -79,7 +79,7 @@ class RemoveCommandTest extends TestCase self::assertEquals(Command::SUCCESS, $appTester->run(['command' => 'remove', 'packages' => ['root/req'], '--update-with-dependencies' => true, '--no-update' => true, '--no-interaction' => true])); self::assertSame('You are using the deprecated option "update-with-dependencies". This is now default behaviour. The --no-update-with-dependencies option can be used to remove a package without its dependencies. ./composer.json has been updated', trim($appTester->getDisplay(true))); - $this->assertEmpty((new JsonFile('./composer.json'))->read()); + self::assertEmpty((new JsonFile('./composer.json'))->read()); } public function testMessageOutputWhenNoUnusedPackagesToRemove(): void diff --git a/tests/Composer/Test/Command/RequireCommandTest.php b/tests/Composer/Test/Command/RequireCommandTest.php index c819a3529..0ab7508d0 100644 --- a/tests/Composer/Test/Command/RequireCommandTest.php +++ b/tests/Composer/Test/Command/RequireCommandTest.php @@ -96,9 +96,9 @@ Installation failed, reverting ./composer.json to its original content. if (str_contains($expected, '%d')) { $pattern = '{^'.str_replace('%d', '[0-9.]+', preg_quote(trim($expected))).'$}'; - $this->assertMatchesRegularExpression($pattern, trim($appTester->getDisplay(true))); + self::assertMatchesRegularExpression($pattern, trim($appTester->getDisplay(true))); } else { - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + self::assertSame(trim($expected), trim($appTester->getDisplay(true))); } } diff --git a/tests/Composer/Test/Command/RunScriptCommandTest.php b/tests/Composer/Test/Command/RunScriptCommandTest.php index dc724ae8d..f69791048 100644 --- a/tests/Composer/Test/Command/RunScriptCommandTest.php +++ b/tests/Composer/Test/Command/RunScriptCommandTest.php @@ -105,8 +105,8 @@ class RunScriptCommandTest extends TestCase $output = $appTester->getDisplay(); - $this->assertStringContainsString('Runs the test script as defined in composer.json', $output, 'The default description for the test script should be printed'); - $this->assertStringContainsString('Run the codestyle fixer', $output, 'The custom description for the fix-cs script should be printed'); + self::assertStringContainsString('Runs the test script as defined in composer.json', $output, 'The default description for the test script should be printed'); + self::assertStringContainsString('Run the codestyle fixer', $output, 'The custom description for the fix-cs script should be printed'); } public function testCanDefineAliases(): void @@ -132,7 +132,7 @@ class RunScriptCommandTest extends TestCase $actualAliases = $array['usage']; array_shift($actualAliases); - $this->assertSame($expectedAliases, $actualAliases, 'The custom aliases for the test command should be printed'); + self::assertSame($expectedAliases, $actualAliases, 'The custom aliases for the test command should be printed'); } public function testExecutionOfCustomSymfonyCommand(): void diff --git a/tests/Composer/Test/Command/SelfUpdateCommandTest.php b/tests/Composer/Test/Command/SelfUpdateCommandTest.php index cc7b579ff..d919dc9d6 100644 --- a/tests/Composer/Test/Command/SelfUpdateCommandTest.php +++ b/tests/Composer/Test/Command/SelfUpdateCommandTest.php @@ -53,7 +53,7 @@ class SelfUpdateCommandTest extends TestCase $appTester->run(['command' => 'self-update']); $appTester->assertCommandIsSuccessful(); - $this->assertStringContainsString('Upgrading to version', $appTester->getDisplay()); + self::assertStringContainsString('Upgrading to version', $appTester->getDisplay()); } public function testUpdateToSpecificVersion(): void @@ -62,7 +62,7 @@ class SelfUpdateCommandTest extends TestCase $appTester->run(['command' => 'self-update', 'version' => '2.4.0']); $appTester->assertCommandIsSuccessful(); - $this->assertStringContainsString('Upgrading to version 2.4.0', $appTester->getDisplay()); + self::assertStringContainsString('Upgrading to version 2.4.0', $appTester->getDisplay()); } public function testUpdateWithInvalidOptionThrowsException(): void @@ -87,8 +87,8 @@ class SelfUpdateCommandTest extends TestCase $appTester->run(['command' => 'self-update', $option => true]); $appTester->assertCommandIsSuccessful(); - $this->assertStringContainsString('Upgrading to version', $appTester->getDisplay()); - $this->assertStringContainsString($expectedOutput, $appTester->getDisplay()); + self::assertStringContainsString('Upgrading to version', $appTester->getDisplay()); + self::assertStringContainsString($expectedOutput, $appTester->getDisplay()); } /** diff --git a/tests/Composer/Test/Command/StatusCommandTest.php b/tests/Composer/Test/Command/StatusCommandTest.php index fce072b02..17d65c3c8 100644 --- a/tests/Composer/Test/Command/StatusCommandTest.php +++ b/tests/Composer/Test/Command/StatusCommandTest.php @@ -30,7 +30,7 @@ class StatusCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(['command' => 'status']); - $this->assertSame('No local changes', trim($appTester->getDisplay(true))); + self::assertSame('No local changes', trim($appTester->getDisplay(true))); } /** @@ -73,8 +73,8 @@ class StatusCommandTest extends TestCase $expected = 'You have changes in the following dependencies:'; $actual = trim($appTester->getDisplay(true)); - $this->assertStringContainsString($expected, $actual); - $this->assertStringContainsString($packageData['name'], $actual); + self::assertStringContainsString($expected, $actual); + self::assertStringContainsString($packageData['name'], $actual); } public static function locallyModifiedPackagesUseCaseProvider(): Generator diff --git a/tests/Composer/Test/Command/UpdateCommandTest.php b/tests/Composer/Test/Command/UpdateCommandTest.php index fce735087..5b58e52d9 100644 --- a/tests/Composer/Test/Command/UpdateCommandTest.php +++ b/tests/Composer/Test/Command/UpdateCommandTest.php @@ -29,7 +29,7 @@ class UpdateCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(array_merge(['command' => 'update', '--dry-run' => true, '--no-audit' => true], $command)); - $this->assertStringMatchesFormat(trim($expected), trim($appTester->getDisplay(true))); + self::assertStringMatchesFormat(trim($expected), trim($appTester->getDisplay(true))); } public static function provideUpdates(): \Generator diff --git a/tests/Composer/Test/Command/ValidateCommandTest.php b/tests/Composer/Test/Command/ValidateCommandTest.php index 363cd0391..bae0b261c 100644 --- a/tests/Composer/Test/Command/ValidateCommandTest.php +++ b/tests/Composer/Test/Command/ValidateCommandTest.php @@ -30,7 +30,7 @@ class ValidateCommandTest extends TestCase $appTester = $this->getApplicationTester(); $appTester->run(array_merge(['command' => 'validate'], $command)); - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + self::assertSame(trim($expected), trim($appTester->getDisplay(true))); } public function testValidateOnFileIssues(): void @@ -42,7 +42,7 @@ class ValidateCommandTest extends TestCase $appTester->run(['command' => 'validate']); $expected = './composer.json not found.'; - $this->assertSame($expected, trim($appTester->getDisplay(true))); + self::assertSame($expected, trim($appTester->getDisplay(true))); } public function testWithComposerLock(): void @@ -63,7 +63,7 @@ Read more about correctly resolving merge conflicts https://getcomposer.org/doc/ and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require-r OUTPUT; - $this->assertSame(trim($expected), trim($appTester->getDisplay(true))); + self::assertSame(trim($expected), trim($appTester->getDisplay(true))); } public function testUnaccessibleFile(): void @@ -79,8 +79,8 @@ OUTPUT; $appTester->run(['command' => 'validate']); $expected = './composer.json is not readable.'; - $this->assertSame($expected, trim($appTester->getDisplay(true))); - $this->assertSame(3, $appTester->getStatusCode()); + self::assertSame($expected, trim($appTester->getDisplay(true))); + self::assertSame(3, $appTester->getStatusCode()); chmod($directory.'/composer.json', 0700); } diff --git a/tests/Composer/Test/CompletionFunctionalTest.php b/tests/Composer/Test/CompletionFunctionalTest.php index cb452f130..1a691af7d 100644 --- a/tests/Composer/Test/CompletionFunctionalTest.php +++ b/tests/Composer/Test/CompletionFunctionalTest.php @@ -136,13 +136,13 @@ class CompletionFunctionalTest extends TestCase $suggestions = $tester->complete($input); if (null === $expectedSuggestions) { - $this->assertEmpty($suggestions); + self::assertEmpty($suggestions); return; } $diff = array_diff($expectedSuggestions, $suggestions); - $this->assertEmpty($diff, sprintf('Suggestions must contain "%s". Got "%s".', implode('", "', $diff), implode('", "', $suggestions))); + self::assertEmpty($diff, sprintf('Suggestions must contain "%s". Got "%s".', implode('", "', $diff), implode('", "', $suggestions))); } private function getApplication(): Application diff --git a/tests/Composer/Test/ComposerTest.php b/tests/Composer/Test/ComposerTest.php index dea0f6a6b..c4bde7df8 100644 --- a/tests/Composer/Test/ComposerTest.php +++ b/tests/Composer/Test/ComposerTest.php @@ -22,7 +22,7 @@ class ComposerTest extends TestCase $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); $composer->setPackage($package); - $this->assertSame($package, $composer->getPackage()); + self::assertSame($package, $composer->getPackage()); } public function testSetGetLocker(): void @@ -31,7 +31,7 @@ class ComposerTest extends TestCase $locker = $this->getMockBuilder('Composer\Package\Locker')->disableOriginalConstructor()->getMock(); $composer->setLocker($locker); - $this->assertSame($locker, $composer->getLocker()); + self::assertSame($locker, $composer->getLocker()); } public function testSetGetRepositoryManager(): void @@ -40,7 +40,7 @@ class ComposerTest extends TestCase $manager = $this->getMockBuilder('Composer\Repository\RepositoryManager')->disableOriginalConstructor()->getMock(); $composer->setRepositoryManager($manager); - $this->assertSame($manager, $composer->getRepositoryManager()); + self::assertSame($manager, $composer->getRepositoryManager()); } public function testSetGetDownloadManager(): void @@ -50,7 +50,7 @@ class ComposerTest extends TestCase $manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')->setConstructorArgs([$io])->getMock(); $composer->setDownloadManager($manager); - $this->assertSame($manager, $composer->getDownloadManager()); + self::assertSame($manager, $composer->getDownloadManager()); } public function testSetGetInstallationManager(): void @@ -59,6 +59,6 @@ class ComposerTest extends TestCase $manager = $this->getMockBuilder('Composer\Installer\InstallationManager')->disableOriginalConstructor()->getMock(); $composer->setInstallationManager($manager); - $this->assertSame($manager, $composer->getInstallationManager()); + self::assertSame($manager, $composer->getInstallationManager()); } } diff --git a/tests/Composer/Test/Config/JsonConfigSourceTest.php b/tests/Composer/Test/Config/JsonConfigSourceTest.php index 536764fc0..9ec1c6868 100644 --- a/tests/Composer/Test/Config/JsonConfigSourceTest.php +++ b/tests/Composer/Test/Config/JsonConfigSourceTest.php @@ -50,7 +50,7 @@ class JsonConfigSourceTest extends TestCase $jsonConfigSource = new JsonConfigSource(new JsonFile($config)); $jsonConfigSource->addRepository('example_tld', ['type' => 'git', 'url' => 'example.tld']); - $this->assertFileEquals(self::fixturePath('config/config-with-exampletld-repository.json'), $config); + self::assertFileEquals(self::fixturePath('config/config-with-exampletld-repository.json'), $config); } public function testAddRepositoryWithOptions(): void @@ -68,7 +68,7 @@ class JsonConfigSourceTest extends TestCase ], ]); - $this->assertFileEquals(self::fixturePath('config/config-with-exampletld-repository-and-options.json'), $config); + self::assertFileEquals(self::fixturePath('config/config-with-exampletld-repository-and-options.json'), $config); } public function testRemoveRepository(): void @@ -78,7 +78,7 @@ class JsonConfigSourceTest extends TestCase $jsonConfigSource = new JsonConfigSource(new JsonFile($config)); $jsonConfigSource->removeRepository('example_tld'); - $this->assertFileEquals(self::fixturePath('composer-repositories.json'), $config); + self::assertFileEquals(self::fixturePath('composer-repositories.json'), $config); } public function testAddPackagistRepositoryWithFalseValue(): void @@ -88,7 +88,7 @@ class JsonConfigSourceTest extends TestCase $jsonConfigSource = new JsonConfigSource(new JsonFile($config)); $jsonConfigSource->addRepository('packagist', false); - $this->assertFileEquals(self::fixturePath('config/config-with-packagist-false.json'), $config); + self::assertFileEquals(self::fixturePath('config/config-with-packagist-false.json'), $config); } public function testRemovePackagist(): void @@ -98,7 +98,7 @@ class JsonConfigSourceTest extends TestCase $jsonConfigSource = new JsonConfigSource(new JsonFile($config)); $jsonConfigSource->removeRepository('packagist'); - $this->assertFileEquals(self::fixturePath('composer-repositories.json'), $config); + self::assertFileEquals(self::fixturePath('composer-repositories.json'), $config); } /** @@ -120,7 +120,7 @@ class JsonConfigSourceTest extends TestCase $jsonConfigSource->addLink($type, $name, $value); - $this->assertFileEquals($compareAgainst, $composerJson); + self::assertFileEquals($compareAgainst, $composerJson); } /** @@ -141,7 +141,7 @@ class JsonConfigSourceTest extends TestCase $jsonConfigSource->removeLink($type, $name); - $this->assertFileEquals($compareAgainst, $composerJson); + self::assertFileEquals($compareAgainst, $composerJson); } /** diff --git a/tests/Composer/Test/ConfigTest.php b/tests/Composer/Test/ConfigTest.php index 08cdfac36..c8677962b 100644 --- a/tests/Composer/Test/ConfigTest.php +++ b/tests/Composer/Test/ConfigTest.php @@ -33,7 +33,7 @@ class ConfigTest extends TestCase } $config->merge(['repositories' => $localConfig]); - $this->assertEquals($expected, $config->getRepositories()); + self::assertEquals($expected, $config->getRepositories()); } public static function dataAddPackagistRepository(): array @@ -149,7 +149,7 @@ class ConfigTest extends TestCase $config->merge(['config' => ['preferred-install' => 'source']]); $config->merge(['config' => ['preferred-install' => 'dist']]); - $this->assertEquals('dist', $config->get('preferred-install')); + self::assertEquals('dist', $config->get('preferred-install')); } public function testMergePreferredInstall(): void @@ -161,7 +161,7 @@ class ConfigTest extends TestCase // This assertion needs to make sure full wildcard preferences are placed last // Handled by composer because we convert string preferences for BC, all other // care for ordering and collision prevention is up to the user - $this->assertEquals(['foo/*' => 'source', '*' => 'dist'], $config->get('preferred-install')); + self::assertEquals(['foo/*' => 'source', '*' => 'dist'], $config->get('preferred-install')); } public function testMergeGithubOauth(): void @@ -170,7 +170,7 @@ class ConfigTest extends TestCase $config->merge(['config' => ['github-oauth' => ['foo' => 'bar']]]); $config->merge(['config' => ['github-oauth' => ['bar' => 'baz']]]); - $this->assertEquals(['foo' => 'bar', 'bar' => 'baz'], $config->get('github-oauth')); + self::assertEquals(['foo' => 'bar', 'bar' => 'baz'], $config->get('github-oauth')); } public function testVarReplacement(): void @@ -180,9 +180,9 @@ class ConfigTest extends TestCase $config->merge(['config' => ['bin-dir' => '$HOME', 'cache-dir' => '~/foo/']]); $home = rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '\\/'); - $this->assertEquals('b', $config->get('c')); - $this->assertEquals($home, $config->get('bin-dir')); - $this->assertEquals($home.'/foo', $config->get('cache-dir')); + self::assertEquals('b', $config->get('c')); + self::assertEquals($home, $config->get('bin-dir')); + self::assertEquals($home.'/foo', $config->get('cache-dir')); } public function testRealpathReplacement(): void @@ -195,9 +195,9 @@ class ConfigTest extends TestCase ]]); $home = rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '\\/'); - $this->assertEquals('/foo/bar/vendor', $config->get('vendor-dir')); - $this->assertEquals($home.'/foo', $config->get('bin-dir')); - $this->assertEquals('/baz', $config->get('cache-dir')); + self::assertEquals('/foo/bar/vendor', $config->get('vendor-dir')); + self::assertEquals($home.'/foo', $config->get('bin-dir')); + self::assertEquals('/baz', $config->get('cache-dir')); } public function testStreamWrapperDirs(): void @@ -207,7 +207,7 @@ class ConfigTest extends TestCase 'cache-dir' => 's3://baz/', ]]); - $this->assertEquals('s3://baz', $config->get('cache-dir')); + self::assertEquals('s3://baz', $config->get('cache-dir')); } public function testFetchingRelativePaths(): void @@ -218,10 +218,10 @@ class ConfigTest extends TestCase 'vendor-dir' => 'vendor', ]]); - $this->assertEquals('/foo/bar/vendor', $config->get('vendor-dir')); - $this->assertEquals('/foo/bar/vendor/foo', $config->get('bin-dir')); - $this->assertEquals('vendor', $config->get('vendor-dir', Config::RELATIVE_PATHS)); - $this->assertEquals('vendor/foo', $config->get('bin-dir', Config::RELATIVE_PATHS)); + self::assertEquals('/foo/bar/vendor', $config->get('vendor-dir')); + self::assertEquals('/foo/bar/vendor/foo', $config->get('bin-dir')); + self::assertEquals('vendor', $config->get('vendor-dir', Config::RELATIVE_PATHS)); + self::assertEquals('vendor/foo', $config->get('bin-dir', Config::RELATIVE_PATHS)); } public function testOverrideGithubProtocols(): void @@ -230,17 +230,17 @@ class ConfigTest extends TestCase $config->merge(['config' => ['github-protocols' => ['https', 'ssh']]]); $config->merge(['config' => ['github-protocols' => ['https']]]); - $this->assertEquals(['https'], $config->get('github-protocols')); + self::assertEquals(['https'], $config->get('github-protocols')); } public function testGitDisabledByDefaultInGithubProtocols(): void { $config = new Config(false); $config->merge(['config' => ['github-protocols' => ['https', 'git']]]); - $this->assertEquals(['https'], $config->get('github-protocols')); + self::assertEquals(['https'], $config->get('github-protocols')); $config->merge(['config' => ['secure-http' => false]]); - $this->assertEquals(['https', 'git'], $config->get('github-protocols')); + self::assertEquals(['https', 'git'], $config->get('github-protocols')); } /** @@ -330,11 +330,11 @@ class ConfigTest extends TestCase $config->merge( ['config' => ['disable-tls' => 'false']] ); - $this->assertFalse($config->get('disable-tls')); + self::assertFalse($config->get('disable-tls')); $config->merge( ['config' => ['disable-tls' => 'true']] ); - $this->assertTrue($config->get('disable-tls')); + self::assertTrue($config->get('disable-tls')); } public function testProcessTimeout(): void @@ -344,7 +344,7 @@ class ConfigTest extends TestCase $result = $config->get('process-timeout'); Platform::clearEnv('COMPOSER_PROCESS_TIMEOUT'); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); } public function testHtaccessProtect(): void @@ -354,7 +354,7 @@ class ConfigTest extends TestCase $result = $config->get('htaccess-protect'); Platform::clearEnv('COMPOSER_HTACCESS_PROTECT'); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); } public function testGetSourceOfValue(): void @@ -363,14 +363,14 @@ class ConfigTest extends TestCase $config = new Config; - $this->assertSame(Config::SOURCE_DEFAULT, $config->getSourceOfValue('process-timeout')); + self::assertSame(Config::SOURCE_DEFAULT, $config->getSourceOfValue('process-timeout')); $config->merge( ['config' => ['process-timeout' => 1]], 'phpunit-test' ); - $this->assertSame('phpunit-test', $config->getSourceOfValue('process-timeout')); + self::assertSame('phpunit-test', $config->getSourceOfValue('process-timeout')); } public function testGetSourceOfValueEnvVariables(): void @@ -380,7 +380,7 @@ class ConfigTest extends TestCase $result = $config->getSourceOfValue('htaccess-protect'); Platform::clearEnv('COMPOSER_HTACCESS_PROTECT'); - $this->assertEquals('COMPOSER_HTACCESS_PROTECT', $result); + self::assertEquals('COMPOSER_HTACCESS_PROTECT', $result); } public function testAudit(): void @@ -420,8 +420,8 @@ class ConfigTest extends TestCase ]; foreach ($keys as $key) { $value = $config->get($key); - $this->assertIsArray($value); // @phpstan-ignore staticMethod.dynamicCall (- PHPStan knows that its an array for all given keys) - $this->assertCount(0, $value); + self::assertIsArray($value); + self::assertCount(0, $value); } } @@ -429,29 +429,29 @@ class ConfigTest extends TestCase { $config = new Config(false); $config->merge(['config' => ['allow-plugins' => ['some/plugin' => true]]]); - $this->assertEquals(['some/plugin' => true], $config->get('allow-plugins')); + self::assertEquals(['some/plugin' => true], $config->get('allow-plugins')); $config->merge(['config' => ['allow-plugins' => ['another/plugin' => true]]]); - $this->assertEquals(['some/plugin' => true, 'another/plugin' => true], $config->get('allow-plugins')); + self::assertEquals(['some/plugin' => true, 'another/plugin' => true], $config->get('allow-plugins')); } public function testOverridesGlobalBooleanPluginsConfig(): void { $config = new Config(false); $config->merge(['config' => ['allow-plugins' => true]]); - $this->assertEquals(true, $config->get('allow-plugins')); + self::assertEquals(true, $config->get('allow-plugins')); $config->merge(['config' => ['allow-plugins' => ['another/plugin' => true]]]); - $this->assertEquals(['another/plugin' => true], $config->get('allow-plugins')); + self::assertEquals(['another/plugin' => true], $config->get('allow-plugins')); } public function testAllowsAllPluginsFromLocalBoolean(): void { $config = new Config(false); $config->merge(['config' => ['allow-plugins' => ['some/plugin' => true]]]); - $this->assertEquals(['some/plugin' => true], $config->get('allow-plugins')); + self::assertEquals(['some/plugin' => true], $config->get('allow-plugins')); $config->merge(['config' => ['allow-plugins' => true]]); - $this->assertEquals(true, $config->get('allow-plugins')); + self::assertEquals(true, $config->get('allow-plugins')); } } diff --git a/tests/Composer/Test/Console/HtmlOutputFormatterTest.php b/tests/Composer/Test/Console/HtmlOutputFormatterTest.php index 6d02a7396..4337fcf60 100644 --- a/tests/Composer/Test/Console/HtmlOutputFormatterTest.php +++ b/tests/Composer/Test/Console/HtmlOutputFormatterTest.php @@ -24,7 +24,7 @@ class HtmlOutputFormatterTest extends TestCase 'warning' => new OutputFormatterStyle('black', 'yellow'), ]); - $this->assertEquals( + self::assertEquals( 'text green yellow black w/ yello bg', $formatter->format('text green yellow black w/ yello bg') ); diff --git a/tests/Composer/Test/DefaultConfigTest.php b/tests/Composer/Test/DefaultConfigTest.php index a49a98ef8..b98da30da 100644 --- a/tests/Composer/Test/DefaultConfigTest.php +++ b/tests/Composer/Test/DefaultConfigTest.php @@ -22,6 +22,6 @@ class DefaultConfigTest extends TestCase public function testDefaultValuesAreAsExpected(): void { $config = new Config; - $this->assertFalse($config->get('disable-tls')); + self::assertFalse($config->get('disable-tls')); } } diff --git a/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php b/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php index 2f888d768..8cb366247 100644 --- a/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php +++ b/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php @@ -53,7 +53,7 @@ class DefaultPolicyTest extends TestCase $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectNewest(): void @@ -69,7 +69,7 @@ class DefaultPolicyTest extends TestCase $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectNewestPicksLatest(): void @@ -85,7 +85,7 @@ class DefaultPolicyTest extends TestCase $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectNewestPicksLatestStableWithPreferStable(): void @@ -102,7 +102,7 @@ class DefaultPolicyTest extends TestCase $policy = new DefaultPolicy(true); $selected = $policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectNewestWithDevPicksNonDev(): void @@ -118,7 +118,7 @@ class DefaultPolicyTest extends TestCase $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectNewestWithPreferredVersionPicksPreferredVersionIfAvailable(): void @@ -137,7 +137,7 @@ class DefaultPolicyTest extends TestCase $policy = new DefaultPolicy(false, false, ['a' => '1.1.0.0']); $selected = $policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectNewestWithPreferredVersionPicksNewestOtherwise(): void @@ -154,7 +154,7 @@ class DefaultPolicyTest extends TestCase $policy = new DefaultPolicy(false, false, ['a' => '1.1.0.0']); $selected = $policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectNewestWithPreferredVersionPicksLowestIfPreferLowest(): void @@ -171,7 +171,7 @@ class DefaultPolicyTest extends TestCase $policy = new DefaultPolicy(false, true, ['a' => '1.1.0.0']); $selected = $policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testRepositoryOrderingAffectsPriority(): void @@ -193,7 +193,7 @@ class DefaultPolicyTest extends TestCase $expected = [$package2->getId()]; $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); $this->repositorySet = new RepositorySet('dev'); $this->repositorySet->addRepository($repo2); @@ -204,7 +204,7 @@ class DefaultPolicyTest extends TestCase $expected = [$package4->getId()]; $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectLocalReposFirst(): void @@ -235,7 +235,7 @@ class DefaultPolicyTest extends TestCase $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectAllProviders(): void @@ -255,7 +255,7 @@ class DefaultPolicyTest extends TestCase $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testPreferNonReplacingFromSameRepo(): void @@ -274,7 +274,7 @@ class DefaultPolicyTest extends TestCase $selected = $this->policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testPreferReplacingPackageFromSameVendor(): void @@ -294,7 +294,7 @@ class DefaultPolicyTest extends TestCase $expected = $literals; $selected = $this->policy->selectPreferredPackages($pool, $literals, 'vendor-a/package'); - $this->assertEquals($expected, $selected); + self::assertEquals($expected, $selected); // test with reversed order in repo $repo = new ArrayRepository; @@ -310,7 +310,7 @@ class DefaultPolicyTest extends TestCase $expected = $literals; $selected = $this->policy->selectPreferredPackages($pool, $literals, 'vendor-a/package'); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } public function testSelectLowest(): void @@ -328,6 +328,6 @@ class DefaultPolicyTest extends TestCase $selected = $policy->selectPreferredPackages($pool, $literals); - $this->assertSame($expected, $selected); + self::assertSame($expected, $selected); } } diff --git a/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php b/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php index 1b66f4319..4feb297ed 100644 --- a/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php +++ b/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php @@ -139,13 +139,13 @@ class PoolBuilderTest extends TestCase sort($expect); sort($result); - $this->assertSame($expect, $result, 'Unoptimized pool does not match expected package set'); + self::assertSame($expect, $result, 'Unoptimized pool does not match expected package set'); $optimizer = new PoolOptimizer(new DefaultPolicy()); $result = $this->getPackageResultSet($optimizer->optimize($request, $pool), $packageIds); sort($expectOptimized); sort($result); - $this->assertSame($expectOptimized, $result, 'Optimized pool does not match expected package set'); + self::assertSame($expectOptimized, $result, 'Optimized pool does not match expected package set'); chdir($oldCwd); } diff --git a/tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php b/tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php index abba7f433..d89745130 100644 --- a/tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php +++ b/tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php @@ -63,7 +63,7 @@ class PoolOptimizerTest extends TestCase $pool = $poolOptimizer->optimize($request, $pool); - $this->assertSame( + self::assertSame( $this->reducePackagesInfoForComparison($expectedPackages), $this->reducePackagesInfoForComparison($pool->getPackages()), $message diff --git a/tests/Composer/Test/DependencyResolver/PoolTest.php b/tests/Composer/Test/DependencyResolver/PoolTest.php index 7e96474ae..839b6c89c 100644 --- a/tests/Composer/Test/DependencyResolver/PoolTest.php +++ b/tests/Composer/Test/DependencyResolver/PoolTest.php @@ -23,8 +23,8 @@ class PoolTest extends TestCase $pool = $this->createPool([$package]); - $this->assertEquals([$package], $pool->whatProvides('foo')); - $this->assertEquals([$package], $pool->whatProvides('foo')); + self::assertEquals([$package], $pool->whatProvides('foo')); + self::assertEquals([$package], $pool->whatProvides('foo')); } public function testWhatProvidesPackageWithConstraint(): void @@ -37,8 +37,8 @@ class PoolTest extends TestCase $secondPackage, ]); - $this->assertEquals([$firstPackage, $secondPackage], $pool->whatProvides('foo')); - $this->assertEquals([$secondPackage], $pool->whatProvides('foo', self::getVersionConstraint('==', '2'))); + self::assertEquals([$firstPackage, $secondPackage], $pool->whatProvides('foo')); + self::assertEquals([$secondPackage], $pool->whatProvides('foo', self::getVersionConstraint('==', '2'))); } public function testPackageById(): void @@ -47,14 +47,14 @@ class PoolTest extends TestCase $pool = $this->createPool([$package]); - $this->assertSame($package, $pool->packageById(1)); + self::assertSame($package, $pool->packageById(1)); } public function testWhatProvidesWhenPackageCannotBeFound(): void { $pool = $this->createPool(); - $this->assertEquals([], $pool->whatProvides('foo')); + self::assertEquals([], $pool->whatProvides('foo')); } /** diff --git a/tests/Composer/Test/DependencyResolver/RequestTest.php b/tests/Composer/Test/DependencyResolver/RequestTest.php index dec915744..5fe4f9286 100644 --- a/tests/Composer/Test/DependencyResolver/RequestTest.php +++ b/tests/Composer/Test/DependencyResolver/RequestTest.php @@ -33,7 +33,7 @@ class RequestTest extends TestCase $request = new Request(); $request->requireName('foo'); - $this->assertEquals( + self::assertEquals( [ 'foo' => new MatchAllConstraint(), ], @@ -55,7 +55,7 @@ class RequestTest extends TestCase $request = new Request(); $request->requireName('foo', $constraint = self::getVersionConstraint('=', '1')); - $this->assertEquals( + self::assertEquals( [ 'foo' => $constraint, ], diff --git a/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php b/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php index d158335d3..1df257dc2 100644 --- a/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php @@ -58,7 +58,7 @@ class RuleSetIteratorTest extends TestCase $this->rules[RuleSet::TYPE_LEARNED][0], ]; - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } public function testKeys(): void @@ -76,6 +76,6 @@ class RuleSetIteratorTest extends TestCase RuleSet::TYPE_LEARNED, ]; - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } } diff --git a/tests/Composer/Test/DependencyResolver/RuleSetTest.php b/tests/Composer/Test/DependencyResolver/RuleSetTest.php index cc8e154c9..acebb74b3 100644 --- a/tests/Composer/Test/DependencyResolver/RuleSetTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleSetTest.php @@ -41,7 +41,7 @@ class RuleSetTest extends TestCase $ruleSet->add($rules[RuleSet::TYPE_LEARNED][0], RuleSet::TYPE_LEARNED); $ruleSet->add($rules[RuleSet::TYPE_REQUEST][1], RuleSet::TYPE_REQUEST); - $this->assertEquals($rules, $ruleSet->getRules()); + self::assertEquals($rules, $ruleSet->getRules()); } public function testAddIgnoresDuplicates(): void @@ -60,7 +60,7 @@ class RuleSetTest extends TestCase $ruleSet->add($rules[RuleSet::TYPE_REQUEST][1], RuleSet::TYPE_REQUEST); $ruleSet->add($rules[RuleSet::TYPE_REQUEST][2], RuleSet::TYPE_REQUEST); - $this->assertCount(1, $ruleSet->getIteratorFor([RuleSet::TYPE_REQUEST])); + self::assertCount(1, $ruleSet->getIteratorFor([RuleSet::TYPE_REQUEST])); } public function testAddWhenTypeIsNotRecognized(): void @@ -79,7 +79,7 @@ class RuleSetTest extends TestCase $ruleSet->add(new GenericRule([1], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]), RuleSet::TYPE_REQUEST); $ruleSet->add(new GenericRule([2], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]), RuleSet::TYPE_REQUEST); - $this->assertEquals(2, $ruleSet->count()); + self::assertEquals(2, $ruleSet->count()); } public function testRuleById(): void @@ -89,7 +89,7 @@ class RuleSetTest extends TestCase $rule = new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $ruleSet->add($rule, RuleSet::TYPE_REQUEST); - $this->assertSame($rule, $ruleSet->ruleById[0]); + self::assertSame($rule, $ruleSet->ruleById[0]); } public function testGetIterator(): void @@ -103,9 +103,9 @@ class RuleSetTest extends TestCase $iterator = $ruleSet->getIterator(); - $this->assertSame($rule1, $iterator->current()); + self::assertSame($rule1, $iterator->current()); $iterator->next(); - $this->assertSame($rule2, $iterator->current()); + self::assertSame($rule2, $iterator->current()); } public function testGetIteratorFor(): void @@ -119,7 +119,7 @@ class RuleSetTest extends TestCase $iterator = $ruleSet->getIteratorFor(RuleSet::TYPE_LEARNED); - $this->assertSame($rule2, $iterator->current()); + self::assertSame($rule2, $iterator->current()); } public function testGetIteratorWithout(): void @@ -133,7 +133,7 @@ class RuleSetTest extends TestCase $iterator = $ruleSet->getIteratorWithout(RuleSet::TYPE_REQUEST); - $this->assertSame($rule2, $iterator->current()); + self::assertSame($rule2, $iterator->current()); } public function testPrettyString(): void @@ -151,6 +151,6 @@ class RuleSetTest extends TestCase $ruleSet->add($rule, RuleSet::TYPE_REQUEST); - $this->assertStringContainsString('REQUEST : No package found to satisfy root composer.json require foo/bar', $ruleSet->getPrettyString($repositorySetMock, $requestMock, $pool)); + self::assertStringContainsString('REQUEST : No package found to satisfy root composer.json require foo/bar', $ruleSet->getPrettyString($repositorySetMock, $requestMock, $pool)); } } diff --git a/tests/Composer/Test/DependencyResolver/RuleTest.php b/tests/Composer/Test/DependencyResolver/RuleTest.php index 4c31c5f77..fe13c2c6c 100644 --- a/tests/Composer/Test/DependencyResolver/RuleTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleTest.php @@ -27,7 +27,7 @@ class RuleTest extends TestCase $rule = new GenericRule([123], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $hash = unpack('ihash', md5('123', true)); - $this->assertEquals($hash['hash'], $rule->getHash()); + self::assertEquals($hash['hash'], $rule->getHash()); } public function testEqualsForRulesWithDifferentHashes(): void @@ -35,7 +35,7 @@ class RuleTest extends TestCase $rule = new GenericRule([1, 2], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $rule2 = new GenericRule([1, 3], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); - $this->assertFalse($rule->equals($rule2)); + self::assertFalse($rule->equals($rule2)); } public function testEqualsForRulesWithDifferLiteralsQuantity(): void @@ -43,7 +43,7 @@ class RuleTest extends TestCase $rule = new GenericRule([1, 12], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $rule2 = new GenericRule([1], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); - $this->assertFalse($rule->equals($rule2)); + self::assertFalse($rule->equals($rule2)); } public function testEqualsForRulesWithSameLiterals(): void @@ -51,7 +51,7 @@ class RuleTest extends TestCase $rule = new GenericRule([1, 12], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $rule2 = new GenericRule([1, 12], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); - $this->assertTrue($rule->equals($rule2)); + self::assertTrue($rule->equals($rule2)); } public function testSetAndGetType(): void @@ -59,7 +59,7 @@ class RuleTest extends TestCase $rule = new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $rule->setType(RuleSet::TYPE_REQUEST); - $this->assertEquals(RuleSet::TYPE_REQUEST, $rule->getType()); + self::assertEquals(RuleSet::TYPE_REQUEST, $rule->getType()); } public function testEnable(): void @@ -68,8 +68,8 @@ class RuleTest extends TestCase $rule->disable(); $rule->enable(); - $this->assertTrue($rule->isEnabled()); - $this->assertFalse($rule->isDisabled()); + self::assertTrue($rule->isEnabled()); + self::assertFalse($rule->isDisabled()); } public function testDisable(): void @@ -78,8 +78,8 @@ class RuleTest extends TestCase $rule->enable(); $rule->disable(); - $this->assertTrue($rule->isDisabled()); - $this->assertFalse($rule->isEnabled()); + self::assertTrue($rule->isDisabled()); + self::assertFalse($rule->isEnabled()); } public function testIsAssertions(): void @@ -87,8 +87,8 @@ class RuleTest extends TestCase $rule = new GenericRule([1, 12], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $rule2 = new GenericRule([1], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); - $this->assertFalse($rule->isAssertion()); - $this->assertTrue($rule2->isAssertion()); + self::assertFalse($rule->isAssertion()); + self::assertTrue($rule2->isAssertion()); } public function testPrettyString(): void @@ -106,6 +106,6 @@ class RuleTest extends TestCase $rule = new GenericRule([$p1->getId(), -$p2->getId()], Rule::RULE_PACKAGE_REQUIRES, new Link('baz', 'foo', $emptyConstraint)); - $this->assertEquals('baz 1.1 relates to foo * -> satisfiable by foo[2.1].', $rule->getPrettyString($repositorySetMock, $requestMock, $pool, false)); + self::assertEquals('baz 1.1 relates to foo * -> satisfiable by foo[2.1].', $rule->getPrettyString($repositorySetMock, $requestMock, $pool, false)); } } diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index 23d0c94e2..c04f3f978 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -94,9 +94,9 @@ class SolverTest extends TestCase $this->fail('Unsolvable conflict did not result in exception.'); } catch (SolverProblemsException $e) { $problems = $e->getProblems(); - $this->assertCount(1, $problems); - $this->assertEquals(2, $e->getCode()); - $this->assertEquals("\n - Root composer.json requires b, it could not be found in any version, there may be a typo in the package name.", $problems[0]->getPrettyString($this->repoSet, $this->request, $this->pool, false)); + self::assertCount(1, $problems); + self::assertEquals(2, $e->getCode()); + self::assertEquals("\n - Root composer.json requires b, it could not be found in any version, there may be a typo in the package name.", $problems[0]->getPrettyString($this->repoSet, $this->request, $this->pool, false)); } } @@ -772,14 +772,14 @@ class SolverTest extends TestCase $this->fail('Unsolvable conflict did not result in exception.'); } catch (SolverProblemsException $e) { $problems = $e->getProblems(); - $this->assertCount(1, $problems); + self::assertCount(1, $problems); $msg = "\n"; $msg .= " Problem 1\n"; $msg .= " - Root composer.json requires a * -> satisfiable by A[1.0].\n"; $msg .= " - A 1.0 conflicts with B 1.0.\n"; $msg .= " - Root composer.json requires b * -> satisfiable by B[1.0].\n"; - $this->assertEquals($msg, $e->getPrettyString($this->repoSet, $this->request, $this->pool, false)); + self::assertEquals($msg, $e->getPrettyString($this->repoSet, $this->request, $this->pool, false)); } } @@ -802,14 +802,14 @@ class SolverTest extends TestCase $this->fail('Unsolvable conflict did not result in exception.'); } catch (SolverProblemsException $e) { $problems = $e->getProblems(); - $this->assertCount(1, $problems); + self::assertCount(1, $problems); // TODO assert problem properties $msg = "\n"; $msg .= " Problem 1\n"; $msg .= " - Root composer.json requires a * -> satisfiable by A[1.0].\n"; $msg .= " - A 1.0 requires b >= 2.0 -> found B[1.0] but it does not match the constraint.\n"; - $this->assertEquals($msg, $e->getPrettyString($this->repoSet, $this->request, $this->pool, false)); + self::assertEquals($msg, $e->getPrettyString($this->repoSet, $this->request, $this->pool, false)); } } @@ -847,7 +847,7 @@ class SolverTest extends TestCase $this->fail('Unsolvable conflict did not result in exception.'); } catch (SolverProblemsException $e) { $problems = $e->getProblems(); - $this->assertCount(1, $problems); + self::assertCount(1, $problems); $msg = "\n"; $msg .= " Problem 1\n"; @@ -857,7 +857,7 @@ class SolverTest extends TestCase $msg .= " - You can only install one version of a package, so only one of these can be installed: B[0.9, 1.0].\n"; $msg .= " - A 1.0 requires b >= 1.0 -> satisfiable by B[1.0].\n"; $msg .= " - Root composer.json requires a * -> satisfiable by A[1.0].\n"; - $this->assertEquals($msg, $e->getPrettyString($this->repoSet, $this->request, $this->pool, false)); + self::assertEquals($msg, $e->getPrettyString($this->repoSet, $this->request, $this->pool, false)); } } @@ -1023,7 +1023,7 @@ class SolverTest extends TestCase $this->createSolver(); // check correct setup for assertion later - $this->assertFalse($this->solver->testFlagLearnedPositiveLiteral); + self::assertFalse($this->solver->testFlagLearnedPositiveLiteral); $this->checkSolverResult([ ['job' => 'install', 'package' => $packageF1], @@ -1037,7 +1037,7 @@ class SolverTest extends TestCase // verify that the code path leading to a negative literal resulting in a positive learned literal is actually // executed - $this->assertTrue($this->solver->testFlagLearnedPositiveLiteral); + self::assertTrue($this->solver->testFlagLearnedPositiveLiteral); } protected function reposComplete(): void @@ -1094,7 +1094,7 @@ class SolverTest extends TestCase $resultReadable[] = array_map('strval', $op); } - $this->assertEquals($expectedReadable, $resultReadable); - $this->assertEquals($expected, $result); + self::assertEquals($expectedReadable, $resultReadable); + self::assertEquals($expected, $result); } } diff --git a/tests/Composer/Test/DependencyResolver/TransactionTest.php b/tests/Composer/Test/DependencyResolver/TransactionTest.php index 554ae3b3f..6b5e230f5 100644 --- a/tests/Composer/Test/DependencyResolver/TransactionTest.php +++ b/tests/Composer/Test/DependencyResolver/TransactionTest.php @@ -122,6 +122,6 @@ class TransactionTest extends TestCase } } - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } } diff --git a/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php b/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php index 36c6404d8..8a56de0e9 100644 --- a/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php +++ b/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php @@ -37,8 +37,8 @@ class ArchiveDownloaderTest extends TestCase ->will($this->returnValue('/vendor')); $first = $method->invoke($downloader, $packageMock, '/path'); - $this->assertMatchesRegularExpression('#/vendor/composer/tmp-[a-z0-9]+\.js#', $first); - $this->assertSame($first, $method->invoke($downloader, $packageMock, '/path')); + self::assertMatchesRegularExpression('#/vendor/composer/tmp-[a-z0-9]+\.js#', $first); + self::assertSame($first, $method->invoke($downloader, $packageMock, '/path')); } public function testProcessUrl(): void @@ -54,7 +54,7 @@ class ArchiveDownloaderTest extends TestCase $expected = 'https://github.com/composer/composer/zipball/master'; $url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected); - $this->assertEquals($expected, $url); + self::assertEquals($expected, $url); } public function testProcessUrl2(): void @@ -70,7 +70,7 @@ class ArchiveDownloaderTest extends TestCase $expected = 'https://github.com/composer/composer/archive/master.tar.gz'; $url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected); - $this->assertEquals($expected, $url); + self::assertEquals($expected, $url); } public function testProcessUrl3(): void @@ -86,7 +86,7 @@ class ArchiveDownloaderTest extends TestCase $expected = 'https://api.github.com/repos/composer/composer/zipball/master'; $url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected); - $this->assertEquals($expected, $url); + self::assertEquals($expected, $url); } /** @@ -111,7 +111,7 @@ class ArchiveDownloaderTest extends TestCase ->will($this->returnValue('ref')); $url = $method->invoke($downloader, $package, $url); - $this->assertEquals($expected, $url); + self::assertEquals($expected, $url); } public static function provideUrls(): array @@ -148,7 +148,7 @@ class ArchiveDownloaderTest extends TestCase ->will($this->returnValue('ref')); $url = $method->invoke($downloader, $package, $url); - $this->assertEquals($expected, $url); + self::assertEquals($expected, $url); } public static function provideBitbucketUrls(): array diff --git a/tests/Composer/Test/Downloader/DownloadManagerTest.php b/tests/Composer/Test/Downloader/DownloadManagerTest.php index 05d169cad..885a17424 100644 --- a/tests/Composer/Test/Downloader/DownloadManagerTest.php +++ b/tests/Composer/Test/Downloader/DownloadManagerTest.php @@ -36,7 +36,7 @@ class DownloadManagerTest extends TestCase $manager = new DownloadManager($this->io, false, $this->filesystem); $manager->setDownloader('test', $downloader); - $this->assertSame($downloader, $manager->getDownloader('test')); + self::assertSame($downloader, $manager->getDownloader('test')); self::expectException('InvalidArgumentException'); $manager->getDownloader('unregistered'); @@ -86,7 +86,7 @@ class DownloadManagerTest extends TestCase ->with('pear') ->will($this->returnValue($downloader)); - $this->assertSame($downloader, $manager->getDownloaderForPackage($package)); + self::assertSame($downloader, $manager->getDownloaderForPackage($package)); } public function testGetDownloaderForIncorrectlyInstalledDistPackage(): void @@ -152,7 +152,7 @@ class DownloadManagerTest extends TestCase ->with('git') ->will($this->returnValue($downloader)); - $this->assertSame($downloader, $manager->getDownloaderForPackage($package)); + self::assertSame($downloader, $manager->getDownloaderForPackage($package)); } public function testGetDownloaderForIncorrectlyInstalledSourcePackage(): void @@ -199,7 +199,7 @@ class DownloadManagerTest extends TestCase $manager = new DownloadManager($this->io, false, $this->filesystem); - $this->assertNull($manager->getDownloaderForPackage($package)); + self::assertNull($manager->getDownloaderForPackage($package)); } public function testFullPackageDownload(): void @@ -264,7 +264,7 @@ class DownloadManagerTest extends TestCase 'source', ]; - $this->assertSame(array_shift($series), $type); + self::assertSame(array_shift($series), $type); }); $downloaderFail = $this->createDownloaderMock(); @@ -674,7 +674,7 @@ class DownloadManagerTest extends TestCase $manager = new DownloadManager($this->io, false, $this->filesystem); $method = new \ReflectionMethod($manager, 'getAvailableSources'); $method->setAccessible(true); - $this->assertEquals($expected, $method->invoke($manager, $target, $initial ?? null)); + self::assertEquals($expected, $method->invoke($manager, $target, $initial ?? null)); } public static function updatesProvider(): array diff --git a/tests/Composer/Test/Downloader/FileDownloaderTest.php b/tests/Composer/Test/Downloader/FileDownloaderTest.php index 0978392f0..967c726bb 100644 --- a/tests/Composer/Test/Downloader/FileDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FileDownloaderTest.php @@ -81,8 +81,8 @@ class FileDownloaderTest extends TestCase } elseif (is_file($path)) { unlink($path); } - $this->assertInstanceOf('RuntimeException', $e); - $this->assertStringContainsString('exists and is not a directory', $e->getMessage()); + self::assertInstanceOf('RuntimeException', $e); + self::assertStringContainsString('exists and is not a directory', $e->getMessage()); } } @@ -96,7 +96,7 @@ class FileDownloaderTest extends TestCase $method = new \ReflectionMethod($downloader, 'getFileName'); $method->setAccessible(true); - $this->assertMatchesRegularExpression('#/vendor/composer/tmp-[a-z0-9]+\.js#', $method->invoke($downloader, $package, '/path')); + self::assertMatchesRegularExpression('#/vendor/composer/tmp-[a-z0-9]+\.js#', $method->invoke($downloader, $package, '/path')); } public function testDownloadButFileIsUnsaved(): void @@ -134,8 +134,8 @@ class FileDownloaderTest extends TestCase unlink($path); } - $this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); - $this->assertStringContainsString('could not be saved to', $e->getMessage()); + self::assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); + self::assertStringContainsString('could not be saved to', $e->getMessage()); } } @@ -176,7 +176,7 @@ class FileDownloaderTest extends TestCase ->expects($this->any()) ->method('copyTo') ->will($this->returnCallback(function ($cacheKey) use ($expectedCacheKey): bool { - $this->assertEquals($expectedCacheKey, $cacheKey, 'Failed assertion on $cacheKey argument of Cache::copyTo method:'); + self::assertEquals($expectedCacheKey, $cacheKey, 'Failed assertion on $cacheKey argument of Cache::copyTo method:'); return false; })); @@ -184,7 +184,7 @@ class FileDownloaderTest extends TestCase ->expects($this->any()) ->method('copyFrom') ->will($this->returnCallback(function ($cacheKey) use ($expectedCacheKey): bool { - $this->assertEquals($expectedCacheKey, $cacheKey, 'Failed assertion on $cacheKey argument of Cache::copyFrom method:'); + self::assertEquals($expectedCacheKey, $cacheKey, 'Failed assertion on $cacheKey argument of Cache::copyFrom method:'); return false; })); @@ -194,7 +194,7 @@ class FileDownloaderTest extends TestCase ->expects($this->any()) ->method('addCopy') ->will($this->returnCallback(function ($url) use ($expectedUrl) { - $this->assertEquals($expectedUrl, $url, 'Failed assertion on $url argument of HttpDownloader::addCopy method:'); + self::assertEquals($expectedUrl, $url, 'Failed assertion on $url argument of HttpDownloader::addCopy method:'); return \React\Promise\resolve( new Response(['url' => 'http://example.org/'], 200, [], 'file~') @@ -217,8 +217,8 @@ class FileDownloaderTest extends TestCase unlink($path); } - $this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); - $this->assertStringContainsString('could not be saved to', $e->getMessage()); + self::assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); + self::assertStringContainsString('could not be saved to', $e->getMessage()); } } @@ -260,7 +260,7 @@ class FileDownloaderTest extends TestCase ->expects($this->any()) ->method('copyTo') ->will($this->returnCallback(function ($cacheKey) use ($expectedCacheKey): bool { - $this->assertEquals($expectedCacheKey, $cacheKey, 'Failed assertion on $cacheKey argument of Cache::copyTo method:'); + self::assertEquals($expectedCacheKey, $cacheKey, 'Failed assertion on $cacheKey argument of Cache::copyTo method:'); return false; })); @@ -268,7 +268,7 @@ class FileDownloaderTest extends TestCase ->expects($this->any()) ->method('copyFrom') ->will($this->returnCallback(function ($cacheKey) use ($expectedCacheKey): bool { - $this->assertEquals($expectedCacheKey, $cacheKey, 'Failed assertion on $cacheKey argument of Cache::copyFrom method:'); + self::assertEquals($expectedCacheKey, $cacheKey, 'Failed assertion on $cacheKey argument of Cache::copyFrom method:'); return false; })); @@ -278,7 +278,7 @@ class FileDownloaderTest extends TestCase ->expects($this->any()) ->method('addCopy') ->will($this->returnCallback(function ($url) use ($expectedUrl) { - $this->assertEquals($expectedUrl, $url, 'Failed assertion on $url argument of HttpDownloader::addCopy method:'); + self::assertEquals($expectedUrl, $url, 'Failed assertion on $url argument of HttpDownloader::addCopy method:'); return \React\Promise\resolve( new Response(['url' => 'http://example.org/'], 200, [], 'file~') @@ -301,8 +301,8 @@ class FileDownloaderTest extends TestCase unlink($path); } - $this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); - $this->assertStringContainsString('could not be saved to', $e->getMessage()); + self::assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); + self::assertStringContainsString('could not be saved to', $e->getMessage()); } } @@ -364,8 +364,8 @@ class FileDownloaderTest extends TestCase unlink($path); } - $this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); - $this->assertStringContainsString('checksum verification', $e->getMessage()); + self::assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); + self::assertStringContainsString('checksum verification', $e->getMessage()); } } diff --git a/tests/Composer/Test/Downloader/FossilDownloaderTest.php b/tests/Composer/Test/Downloader/FossilDownloaderTest.php index c04450ab1..7ab784357 100644 --- a/tests/Composer/Test/Downloader/FossilDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FossilDownloaderTest.php @@ -162,6 +162,6 @@ class FossilDownloaderTest extends TestCase { $downloader = $this->getDownloaderMock(null); - $this->assertEquals('source', $downloader->getInstallationSource()); + self::assertEquals('source', $downloader->getInstallationSource()); } } diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 5411767e5..0abc0df59 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -304,7 +304,7 @@ class GitDownloaderTest extends TestCase if ('RuntimeException' !== get_class($e)) { throw $e; } - $this->assertEquals('RuntimeException', get_class($e)); + self::assertEquals('RuntimeException', get_class($e)); } } @@ -461,7 +461,7 @@ composer https://github.com/old/url (push) if ('RuntimeException' !== get_class($e)) { throw $e; } - $this->assertEquals('RuntimeException', get_class($e)); + self::assertEquals('RuntimeException', get_class($e)); } } @@ -631,7 +631,7 @@ composer https://github.com/old/url (push) { $downloader = $this->getDownloaderMock(); - $this->assertEquals('source', $downloader->getInstallationSource()); + self::assertEquals('source', $downloader->getInstallationSource()); } private function winCompat(string $cmd): string diff --git a/tests/Composer/Test/Downloader/HgDownloaderTest.php b/tests/Composer/Test/Downloader/HgDownloaderTest.php index bdb8bde3e..544d52994 100644 --- a/tests/Composer/Test/Downloader/HgDownloaderTest.php +++ b/tests/Composer/Test/Downloader/HgDownloaderTest.php @@ -154,6 +154,6 @@ class HgDownloaderTest extends TestCase { $downloader = $this->getDownloaderMock(null); - $this->assertEquals('source', $downloader->getInstallationSource()); + self::assertEquals('source', $downloader->getInstallationSource()); } } diff --git a/tests/Composer/Test/Downloader/XzDownloaderTest.php b/tests/Composer/Test/Downloader/XzDownloaderTest.php index 83f54c884..1cabefb56 100644 --- a/tests/Composer/Test/Downloader/XzDownloaderTest.php +++ b/tests/Composer/Test/Downloader/XzDownloaderTest.php @@ -66,7 +66,7 @@ class XzDownloaderTest extends TestCase $this->fail('Download of invalid tarball should throw an exception'); } catch (\RuntimeException $e) { - $this->assertMatchesRegularExpression('/(File format not recognized|Unrecognized archive format)/i', $e->getMessage()); + self::assertMatchesRegularExpression('/(File format not recognized|Unrecognized archive format)/i', $e->getMessage()); } } } diff --git a/tests/Composer/Test/Downloader/ZipDownloaderTest.php b/tests/Composer/Test/Downloader/ZipDownloaderTest.php index 1155ec6b8..c5c168831 100644 --- a/tests/Composer/Test/Downloader/ZipDownloaderTest.php +++ b/tests/Composer/Test/Downloader/ZipDownloaderTest.php @@ -102,7 +102,7 @@ class ZipDownloaderTest extends TestCase $this->fail('Download of invalid zip files should throw an exception'); } catch (\Exception $e) { - $this->assertStringContainsString('is not a zip archive', $e->getMessage()); + self::assertStringContainsString('is not a zip archive', $e->getMessage()); } } diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php index f0a7ecc5f..233317c03 100644 --- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php +++ b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php @@ -200,7 +200,7 @@ class EventDispatcherTest extends TestCase .'> ev1: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL .'> ev2: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL .'> ev2: Composer\Test\EventDispatcher\EventDispatcherTest->someMethod'.PHP_EOL; - $this->assertEquals($expected, $io->getOutput()); + self::assertEquals($expected, $io->getOutput()); $dispatcher->removeListener($this); $dispatcher->dispatch('ev1'); @@ -208,7 +208,7 @@ class EventDispatcherTest extends TestCase $expected .= '> ev1: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL .'> ev2: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL; - $this->assertEquals($expected, $io->getOutput()); + self::assertEquals($expected, $io->getOutput()); } public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack(): void @@ -245,7 +245,7 @@ class EventDispatcherTest extends TestCase $expected = '> post-install-cmd: echo -n foo'.PHP_EOL. '> post-install-cmd: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL. '> post-install-cmd: echo -n bar'.PHP_EOL; - $this->assertEquals($expected, $io->getOutput()); + self::assertEquals($expected, $io->getOutput()); } public function testDispatcherCanPutEnv(): void @@ -274,7 +274,7 @@ class EventDispatcherTest extends TestCase $expected = '> post-install-cmd: @putenv ABC=123'.PHP_EOL. '> post-install-cmd: Composer\Test\EventDispatcher\EventDispatcherTest::getTestEnv'.PHP_EOL; - $this->assertEquals($expected, $io->getOutput()); + self::assertEquals($expected, $io->getOutput()); } public function testDispatcherAppendsDirBinOnPathForEveryListener(): void @@ -386,7 +386,7 @@ class EventDispatcherTest extends TestCase '> group: @subgroup'.PHP_EOL. '> subgroup: echo -n baz'.PHP_EOL. '> group: echo -n bar'.PHP_EOL; - $this->assertEquals($expected, $io->getOutput()); + self::assertEquals($expected, $io->getOutput()); } public function testRecursionInScriptsNames(): void @@ -425,7 +425,7 @@ class EventDispatcherTest extends TestCase $expected = "> helloWorld: @hello World".PHP_EOL. "> hello: echo Hello " .self::getCmd("'World'").PHP_EOL; - $this->assertEquals($expected, $io->getOutput()); + self::assertEquals($expected, $io->getOutput()); } public function testDispatcherDetectInfiniteRecursion(): void diff --git a/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreAllPlatformRequirementFilterTest.php b/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreAllPlatformRequirementFilterTest.php index 8d148ec7c..67d212720 100644 --- a/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreAllPlatformRequirementFilterTest.php +++ b/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreAllPlatformRequirementFilterTest.php @@ -24,8 +24,8 @@ final class IgnoreAllPlatformRequirementFilterTest extends TestCase { $platformRequirementFilter = new IgnoreAllPlatformRequirementFilter(); - $this->assertSame($expectIgnored, $platformRequirementFilter->isIgnored($req)); - $this->assertSame($expectIgnored, $platformRequirementFilter->isUpperBoundIgnored($req)); + self::assertSame($expectIgnored, $platformRequirementFilter->isIgnored($req)); + self::assertSame($expectIgnored, $platformRequirementFilter->isUpperBoundIgnored($req)); } /** diff --git a/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilterTest.php b/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilterTest.php index 5f3cc1f51..30ff79bbc 100644 --- a/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilterTest.php +++ b/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilterTest.php @@ -26,7 +26,7 @@ final class IgnoreListPlatformRequirementFilterTest extends TestCase { $platformRequirementFilter = new IgnoreListPlatformRequirementFilter($reqList); - $this->assertSame($expectIgnored, $platformRequirementFilter->isIgnored($req)); + self::assertSame($expectIgnored, $platformRequirementFilter->isIgnored($req)); } /** @@ -58,7 +58,7 @@ final class IgnoreListPlatformRequirementFilterTest extends TestCase { $platformRequirementFilter = new IgnoreListPlatformRequirementFilter($reqList); - $this->assertSame($expectIgnored, $platformRequirementFilter->isUpperBoundIgnored($req)); + self::assertSame($expectIgnored, $platformRequirementFilter->isUpperBoundIgnored($req)); } /** diff --git a/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilterTest.php b/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilterTest.php index 36fb69ba5..512e74771 100644 --- a/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilterTest.php +++ b/tests/Composer/Test/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilterTest.php @@ -24,8 +24,8 @@ final class IgnoreNothingPlatformRequirementFilterTest extends TestCase { $platformRequirementFilter = new IgnoreNothingPlatformRequirementFilter(); - $this->assertFalse($platformRequirementFilter->isIgnored($req)); // @phpstan-ignore staticMethod.dynamicCall - $this->assertFalse($platformRequirementFilter->isUpperBoundIgnored($req)); // @phpstan-ignore staticMethod.dynamicCall + self::assertFalse($platformRequirementFilter->isIgnored($req)); + self::assertFalse($platformRequirementFilter->isUpperBoundIgnored($req)); } /** diff --git a/tests/Composer/Test/Filter/PlatformRequirementFilter/PlatformRequirementFilterFactoryTest.php b/tests/Composer/Test/Filter/PlatformRequirementFilter/PlatformRequirementFilterFactoryTest.php index 7fa9feba3..b8c1c795d 100644 --- a/tests/Composer/Test/Filter/PlatformRequirementFilter/PlatformRequirementFilterFactoryTest.php +++ b/tests/Composer/Test/Filter/PlatformRequirementFilter/PlatformRequirementFilterFactoryTest.php @@ -25,7 +25,7 @@ final class PlatformRequirementFilterFactoryTest extends TestCase */ public function testFromBoolOrList($boolOrList, $expectedInstance): void { - $this->assertInstanceOf($expectedInstance, PlatformRequirementFilterFactory::fromBoolOrList($boolOrList)); + self::assertInstanceOf($expectedInstance, PlatformRequirementFilterFactory::fromBoolOrList($boolOrList)); } /** @@ -52,13 +52,13 @@ final class PlatformRequirementFilterFactoryTest extends TestCase { $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreAll(); - $this->assertInstanceOf('Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter', $platformRequirementFilter); + self::assertInstanceOf('Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter', $platformRequirementFilter); } public function testIgnoreNothing(): void { $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing(); - $this->assertInstanceOf('Composer\Filter\PlatformRequirementFilter\IgnoreNothingPlatformRequirementFilter', $platformRequirementFilter); + self::assertInstanceOf('Composer\Filter\PlatformRequirementFilter\IgnoreNothingPlatformRequirementFilter', $platformRequirementFilter); } } diff --git a/tests/Composer/Test/IO/BufferIOTest.php b/tests/Composer/Test/IO/BufferIOTest.php index 0cf979677..9ee7d7f0e 100644 --- a/tests/Composer/Test/IO/BufferIOTest.php +++ b/tests/Composer/Test/IO/BufferIOTest.php @@ -37,8 +37,8 @@ class BufferIOTest extends TestCase '', ]); - $this->assertTrue($bufferIO->askConfirmation('Please say yes!', false)); - $this->assertFalse($bufferIO->askConfirmation('Now please say no!', true)); - $this->assertSame('default', $bufferIO->ask('Empty string last', 'default')); + self::assertTrue($bufferIO->askConfirmation('Please say yes!', false)); + self::assertFalse($bufferIO->askConfirmation('Now please say no!', true)); + self::assertSame('default', $bufferIO->ask('Empty string last', 'default')); } } diff --git a/tests/Composer/Test/IO/ConsoleIOTest.php b/tests/Composer/Test/IO/ConsoleIOTest.php index 2d152eb61..ddac19b27 100644 --- a/tests/Composer/Test/IO/ConsoleIOTest.php +++ b/tests/Composer/Test/IO/ConsoleIOTest.php @@ -34,8 +34,8 @@ class ConsoleIOTest extends TestCase $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); - $this->assertTrue($consoleIO->isInteractive()); - $this->assertFalse($consoleIO->isInteractive()); + self::assertTrue($consoleIO->isInteractive()); + self::assertFalse($consoleIO->isInteractive()); } public function testWrite(): void @@ -127,7 +127,7 @@ class ConsoleIOTest extends TestCase } if (count($series) > 0) { - $this->assertSame(array_shift($series), [$args[0], $args[1]]); + self::assertSame(array_shift($series), [$args[0], $args[1]]); } }); @@ -252,7 +252,7 @@ class ConsoleIOTest extends TestCase $consoleIO = new ConsoleIO($inputMock, $outputMock, $setMock); $result = $consoleIO->select('Select item', ["item1", "item2"], 'item1', false, "Error message", true); - $this->assertEquals(['1'], $result); + self::assertEquals(['1'], $result); } public function testSetAndgetAuthentication(): void @@ -264,7 +264,7 @@ class ConsoleIOTest extends TestCase $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); - $this->assertEquals( + self::assertEquals( ['username' => 'l3l0', 'password' => 'passwd'], $consoleIO->getAuthentication('repoName') ); @@ -278,7 +278,7 @@ class ConsoleIOTest extends TestCase $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); - $this->assertEquals( + self::assertEquals( ['username' => null, 'password' => null], $consoleIO->getAuthentication('repoName') ); @@ -293,7 +293,7 @@ class ConsoleIOTest extends TestCase $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); - $this->assertTrue($consoleIO->hasAuthentication('repoName')); - $this->assertFalse($consoleIO->hasAuthentication('repoName2')); + self::assertTrue($consoleIO->hasAuthentication('repoName')); + self::assertFalse($consoleIO->hasAuthentication('repoName2')); } } diff --git a/tests/Composer/Test/IO/NullIOTest.php b/tests/Composer/Test/IO/NullIOTest.php index 6bc3aa043..987ea7071 100644 --- a/tests/Composer/Test/IO/NullIOTest.php +++ b/tests/Composer/Test/IO/NullIOTest.php @@ -21,51 +21,51 @@ class NullIOTest extends TestCase { $io = new NullIO(); - $this->assertFalse($io->isInteractive()); + self::assertFalse($io->isInteractive()); } public function testhasAuthentication(): void { $io = new NullIO(); - $this->assertFalse($io->hasAuthentication('foo')); + self::assertFalse($io->hasAuthentication('foo')); } public function testAskAndHideAnswer(): void { $io = new NullIO(); - $this->assertNull($io->askAndHideAnswer('foo')); + self::assertNull($io->askAndHideAnswer('foo')); } public function testgetAuthentications(): void { $io = new NullIO(); - $this->assertIsArray($io->getAuthentications()); // @phpstan-ignore staticMethod.dynamicCall - $this->assertEmpty($io->getAuthentications()); - $this->assertEquals(['username' => null, 'password' => null], $io->getAuthentication('foo')); + self::assertIsArray($io->getAuthentications()); + self::assertEmpty($io->getAuthentications()); + self::assertEquals(['username' => null, 'password' => null], $io->getAuthentication('foo')); } public function testAsk(): void { $io = new NullIO(); - $this->assertEquals('foo', $io->ask('bar', 'foo')); + self::assertEquals('foo', $io->ask('bar', 'foo')); } public function testAskConfirmation(): void { $io = new NullIO(); - $this->assertEquals(false, $io->askConfirmation('bar', false)); + self::assertEquals(false, $io->askConfirmation('bar', false)); } public function testAskAndValidate(): void { $io = new NullIO(); - $this->assertEquals('foo', $io->askAndValidate('question', static function ($x): bool { + self::assertEquals('foo', $io->askAndValidate('question', static function ($x): bool { return true; }, null, 'foo')); } @@ -74,6 +74,6 @@ class NullIOTest extends TestCase { $io = new NullIO(); - $this->assertEquals('1', $io->select('question', ['item1', 'item2'], '1', 2, 'foo', true)); + self::assertEquals('1', $io->select('question', ['item1', 'item2'], '1', 2, 'foo', true)); } } diff --git a/tests/Composer/Test/InstalledVersionsTest.php b/tests/Composer/Test/InstalledVersionsTest.php index 7e34f7e37..fdcf28fbb 100644 --- a/tests/Composer/Test/InstalledVersionsTest.php +++ b/tests/Composer/Test/InstalledVersionsTest.php @@ -65,7 +65,7 @@ class InstalledVersionsTest extends TestCase 'foo/replaced', 'meta/package', ]; - $this->assertSame($names, InstalledVersions::getInstalledPackages()); + self::assertSame($names, InstalledVersions::getInstalledPackages()); } /** @@ -73,7 +73,7 @@ class InstalledVersionsTest extends TestCase */ public function testIsInstalled(bool $expected, string $name, bool $includeDevRequirements = true): void { - $this->assertSame($expected, InstalledVersions::isInstalled($name, $includeDevRequirements)); + self::assertSame($expected, InstalledVersions::isInstalled($name, $includeDevRequirements)); } public static function isInstalledProvider(): array @@ -95,7 +95,7 @@ class InstalledVersionsTest extends TestCase */ public function testSatisfies(bool $expected, string $name, string $constraint): void { - $this->assertSame($expected, InstalledVersions::satisfies(new VersionParser, $name, $constraint)); + self::assertSame($expected, InstalledVersions::satisfies(new VersionParser, $name, $constraint)); } public static function satisfiesProvider(): array @@ -133,7 +133,7 @@ class InstalledVersionsTest extends TestCase */ public function testGetVersionRanges(string $expected, string $name): void { - $this->assertSame($expected, InstalledVersions::getVersionRanges($name)); + self::assertSame($expected, InstalledVersions::getVersionRanges($name)); } public static function getVersionRangesProvider(): array @@ -155,7 +155,7 @@ class InstalledVersionsTest extends TestCase */ public function testGetVersion(?string $expected, string $name): void { - $this->assertSame($expected, InstalledVersions::getVersion($name)); + self::assertSame($expected, InstalledVersions::getVersion($name)); } public static function getVersionProvider(): array @@ -177,7 +177,7 @@ class InstalledVersionsTest extends TestCase */ public function testGetPrettyVersion(?string $expected, string $name): void { - $this->assertSame($expected, InstalledVersions::getPrettyVersion($name)); + self::assertSame($expected, InstalledVersions::getPrettyVersion($name)); } public static function getPrettyVersionProvider(): array @@ -202,7 +202,7 @@ class InstalledVersionsTest extends TestCase public function testGetRootPackage(): void { - $this->assertSame([ + self::assertSame([ 'name' => '__root__', 'pretty_version' => 'dev-master', 'version' => 'dev-master', @@ -222,7 +222,7 @@ class InstalledVersionsTest extends TestCase public function testGetRawData(): void { $dir = $this->root; - $this->assertSame(require __DIR__.'/Repository/Fixtures/installed_relative.php', InstalledVersions::getRawData()); + self::assertSame(require __DIR__.'/Repository/Fixtures/installed_relative.php', InstalledVersions::getRawData()); } /** @@ -230,7 +230,7 @@ class InstalledVersionsTest extends TestCase */ public function testGetReference(?string $expected, string $name): void { - $this->assertSame($expected, InstalledVersions::getReference($name)); + self::assertSame($expected, InstalledVersions::getReference($name)); } public static function getReferenceProvider(): array @@ -257,13 +257,13 @@ class InstalledVersionsTest extends TestCase 'c/c', ]; - $this->assertSame($names, \Composer\InstalledVersions::getInstalledPackagesByType('library')); + self::assertSame($names, \Composer\InstalledVersions::getInstalledPackagesByType('library')); } public function testGetInstallPath(): void { - $this->assertSame(realpath($this->root), realpath(\Composer\InstalledVersions::getInstallPath('__root__'))); - $this->assertSame('/foo/bar/vendor/c/c', \Composer\InstalledVersions::getInstallPath('c/c')); - $this->assertNull(\Composer\InstalledVersions::getInstallPath('foo/impl')); + self::assertSame(realpath($this->root), realpath(\Composer\InstalledVersions::getInstallPath('__root__'))); + self::assertSame('/foo/bar/vendor/c/c', \Composer\InstalledVersions::getInstallPath('c/c')); + self::assertNull(\Composer\InstalledVersions::getInstallPath('foo/impl')); } } diff --git a/tests/Composer/Test/Installer/BinaryInstallerTest.php b/tests/Composer/Test/Installer/BinaryInstallerTest.php index 8b6d47243..00f6ce618 100644 --- a/tests/Composer/Test/Installer/BinaryInstallerTest.php +++ b/tests/Composer/Test/Installer/BinaryInstallerTest.php @@ -82,8 +82,8 @@ class BinaryInstallerTest extends TestCase $proc = new ProcessExecutor(); $proc->execute($this->binDir.'/binary arg', $output); - $this->assertEquals('', $proc->getErrorOutput()); - $this->assertEquals('success arg', $output); + self::assertEquals('', $proc->getErrorOutput()); + self::assertEquals('success arg', $output); } public static function executableBinaryProvider(): array diff --git a/tests/Composer/Test/Installer/InstallationManagerTest.php b/tests/Composer/Test/Installer/InstallationManagerTest.php index d1c7746d0..f253176bb 100644 --- a/tests/Composer/Test/Installer/InstallationManagerTest.php +++ b/tests/Composer/Test/Installer/InstallationManagerTest.php @@ -57,7 +57,7 @@ class InstallationManagerTest extends TestCase $manager = new InstallationManager($this->loop, $this->io); $manager->addInstaller($installer); - $this->assertSame($installer, $manager->getInstaller('vendor')); + self::assertSame($installer, $manager->getInstaller('vendor')); self::expectException('InvalidArgumentException'); $manager->getInstaller('unregistered'); @@ -86,11 +86,11 @@ class InstallationManagerTest extends TestCase $manager = new InstallationManager($this->loop, $this->io); $manager->addInstaller($installer); - $this->assertSame($installer, $manager->getInstaller('vendor')); + self::assertSame($installer, $manager->getInstaller('vendor')); $manager->addInstaller($installer2); - $this->assertSame($installer2, $manager->getInstaller('vendor')); + self::assertSame($installer2, $manager->getInstaller('vendor')); $manager->removeInstaller($installer2); - $this->assertSame($installer, $manager->getInstaller('vendor')); + self::assertSame($installer, $manager->getInstaller('vendor')); } public function testExecute(): void diff --git a/tests/Composer/Test/Installer/InstallerEventTest.php b/tests/Composer/Test/Installer/InstallerEventTest.php index 834f7ac7b..de87ba7b8 100644 --- a/tests/Composer/Test/Installer/InstallerEventTest.php +++ b/tests/Composer/Test/Installer/InstallerEventTest.php @@ -24,11 +24,9 @@ class InstallerEventTest extends TestCase $transaction = $this->getMockBuilder('Composer\DependencyResolver\LockTransaction')->disableOriginalConstructor()->getMock(); $event = new InstallerEvent('EVENT_NAME', $composer, $io, true, true, $transaction); - $this->assertSame('EVENT_NAME', $event->getName()); - $this->assertInstanceOf('Composer\Composer', $event->getComposer()); - $this->assertInstanceOf('Composer\IO\IOInterface', $event->getIO()); - $this->assertTrue($event->isDevMode()); - $this->assertTrue($event->isExecutingOperations()); - $this->assertInstanceOf('Composer\DependencyResolver\Transaction', $event->getTransaction()); + self::assertSame('EVENT_NAME', $event->getName()); + self::assertTrue($event->isDevMode()); + self::assertTrue($event->isExecutingOperations()); + self::assertInstanceOf('Composer\DependencyResolver\Transaction', $event->getTransaction()); } } diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php index 3161687de..aa63eb224 100644 --- a/tests/Composer/Test/Installer/LibraryInstallerTest.php +++ b/tests/Composer/Test/Installer/LibraryInstallerTest.php @@ -108,7 +108,7 @@ class LibraryInstallerTest extends TestCase $this->fs->removeDirectory($this->vendorDir); new LibraryInstaller($this->io, $this->composer); - $this->assertFileDoesNotExist($this->vendorDir); + self::assertFileDoesNotExist($this->vendorDir); } public function testInstallerCreationShouldNotCreateBinDirectory(): void @@ -116,7 +116,7 @@ class LibraryInstallerTest extends TestCase $this->fs->removeDirectory($this->binDir); new LibraryInstaller($this->io, $this->composer); - $this->assertFileDoesNotExist($this->binDir); + self::assertFileDoesNotExist($this->binDir); } public function testIsInstalled(): void @@ -125,18 +125,18 @@ class LibraryInstallerTest extends TestCase $package = self::getPackage('test/pkg', '1.0.0'); $repository = new InstalledArrayRepository(); - $this->assertFalse($library->isInstalled($repository, $package)); + self::assertFalse($library->isInstalled($repository, $package)); // package being in repo is not enough to be installed $repository->addPackage($package); - $this->assertFalse($library->isInstalled($repository, $package)); + self::assertFalse($library->isInstalled($repository, $package)); // package being in repo and vendor/pkg/foo dir present means it is seen as installed self::ensureDirectoryExistsAndClear($this->vendorDir.'/'.$package->getPrettyName()); - $this->assertTrue($library->isInstalled($repository, $package)); + self::assertTrue($library->isInstalled($repository, $package)); $repository->removePackage($package); - $this->assertFalse($library->isInstalled($repository, $package)); + self::assertFalse($library->isInstalled($repository, $package)); } /** @@ -160,8 +160,8 @@ class LibraryInstallerTest extends TestCase ->with($package); $library->install($this->repository, $package); - $this->assertFileExists($this->vendorDir, 'Vendor dir should be created'); - $this->assertFileExists($this->binDir, 'Bin dir should be created'); + self::assertFileExists($this->vendorDir, 'Vendor dir should be created'); + self::assertFileExists($this->binDir, 'Bin dir should be created'); } /** @@ -206,8 +206,8 @@ class LibraryInstallerTest extends TestCase $library = new LibraryInstaller($this->io, $this->composer, 'library', $filesystem); $library->update($this->repository, $initial, $target); - $this->assertFileExists($this->vendorDir, 'Vendor dir should be created'); - $this->assertFileExists($this->binDir, 'Bin dir should be created'); + self::assertFileExists($this->vendorDir, 'Vendor dir should be created'); + self::assertFileExists($this->binDir, 'Bin dir should be created'); self::expectException('InvalidArgumentException'); @@ -248,7 +248,7 @@ class LibraryInstallerTest extends TestCase $library = new LibraryInstaller($this->io, $this->composer); $package = self::getPackage('Vendor/Pkg', '1.0.0'); - $this->assertEquals($this->vendorDir.'/'.$package->getPrettyName(), $library->getInstallPath($package)); + self::assertEquals($this->vendorDir.'/'.$package->getPrettyName(), $library->getInstallPath($package)); } public function testGetInstallPathWithTargetDir(): void @@ -257,7 +257,7 @@ class LibraryInstallerTest extends TestCase $package = self::getPackage('Foo/Bar', '1.0.0'); $package->setTargetDir('Some/Namespace'); - $this->assertEquals($this->vendorDir.'/'.$package->getPrettyName().'/Some/Namespace', $library->getInstallPath($package)); + self::assertEquals($this->vendorDir.'/'.$package->getPrettyName().'/Some/Namespace', $library->getInstallPath($package)); } /** diff --git a/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php b/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php index a9969c4f4..3f412c3d4 100644 --- a/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php +++ b/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php @@ -56,7 +56,7 @@ class SuggestedPackagesReporterTest extends TestCase */ public function testGetPackagesEmptyByDefault(): void { - $this->assertEmpty($this->suggestedPackagesReporter->getPackages()); + self::assertEmpty($this->suggestedPackagesReporter->getPackages()); } /** @@ -71,7 +71,7 @@ class SuggestedPackagesReporterTest extends TestCase $suggestedPackage['target'], $suggestedPackage['reason'] ); - $this->assertSame( + self::assertSame( [$suggestedPackage], $this->suggestedPackagesReporter->getPackages() ); @@ -99,7 +99,7 @@ class SuggestedPackagesReporterTest extends TestCase $suggestedPackageB['target'], $suggestedPackageB['reason'] ); - $this->assertSame( + self::assertSame( [$suggestedPackageA, $suggestedPackageB], $this->suggestedPackagesReporter->getPackages() ); @@ -122,7 +122,7 @@ class SuggestedPackagesReporterTest extends TestCase ->will($this->returnValue('package-pretty-name')); $this->suggestedPackagesReporter->addSuggestionsFromPackage($package); - $this->assertSame([ + self::assertSame([ [ 'source' => 'package-pretty-name', 'target' => 'target-a', diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 490eac996..cecbdd942 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -138,20 +138,20 @@ class InstallerTest extends TestCase $result = $installer->run(); $output = str_replace("\r", '', $io->getOutput()); - $this->assertEquals(0, $result, $output); + self::assertEquals(0, $result, $output); $expectedInstalled = $options['install'] ?? []; $expectedUpdated = $options['update'] ?? []; $expectedUninstalled = $options['uninstall'] ?? []; $installed = $installationManager->getInstalledPackages(); - $this->assertEquals($this->makePackagesComparable($expectedInstalled), $this->makePackagesComparable($installed)); + self::assertEquals($this->makePackagesComparable($expectedInstalled), $this->makePackagesComparable($installed)); $updated = $installationManager->getUpdatedPackages(); - $this->assertSame($expectedUpdated, $updated); + self::assertSame($expectedUpdated, $updated); $uninstalled = $installationManager->getUninstalledPackages(); - $this->assertSame($expectedUninstalled, $uninstalled); + self::assertSame($expectedUninstalled, $uninstalled); } /** @@ -441,10 +441,10 @@ class InstallerTest extends TestCase } $output = str_replace("\r", '', $io->getOutput()); - $this->assertEquals($expectResult, $result, $output . stream_get_contents($appOutput)); + self::assertEquals($expectResult, $result, $output . stream_get_contents($appOutput)); if ($expectLock && isset($actualLock)) { unset($actualLock['hash'], $actualLock['content-hash'], $actualLock['_readme'], $actualLock['plugin-api-version']); - $this->assertEquals($expectLock, $actualLock); + self::assertEquals($expectLock, $actualLock); } if ($expectInstalled !== null) { @@ -461,18 +461,18 @@ class InstallerTest extends TestCase return strcmp($a['name'], $b['name']); }); - $this->assertSame($expectInstalled, $actualInstalled); + self::assertSame($expectInstalled, $actualInstalled); } /** @var InstallationManagerMock $installationManager */ $installationManager = $composer->getInstallationManager(); - $this->assertSame(rtrim($expect), implode("\n", $installationManager->getTrace())); + self::assertSame(rtrim($expect), implode("\n", $installationManager->getTrace())); if ($expectOutput) { $output = Preg::replace('{^ - .*?\.ini$}m', '__inilist__', $output); $output = Preg::replace('{(__inilist__\r?\n)+}', "__inilist__\n", $output); - $this->assertStringMatchesFormat(rtrim($expectOutput), rtrim($output)); + self::assertStringMatchesFormat(rtrim($expectOutput), rtrim($output)); } } diff --git a/tests/Composer/Test/Json/ComposerSchemaTest.php b/tests/Composer/Test/Json/ComposerSchemaTest.php index 9a6735091..4a2acee3d 100644 --- a/tests/Composer/Test/Json/ComposerSchemaTest.php +++ b/tests/Composer/Test/Json/ComposerSchemaTest.php @@ -33,21 +33,21 @@ class ComposerSchemaTest extends TestCase ]; $json = '{"name": "vendor/-pack__age", "description": "description"}'; - $this->assertEquals($expectedError, $this->check($json)); + self::assertEquals($expectedError, $this->check($json)); $json = '{"name": "Vendor/Package", "description": "description"}'; - $this->assertEquals($expectedError, $this->check($json)); + self::assertEquals($expectedError, $this->check($json)); } public function testOptionalAbandonedProperty(): void { $json = '{"name": "vendor/package", "description": "description", "abandoned": true}'; - $this->assertTrue($this->check($json)); + self::assertTrue($this->check($json)); } public function testRequireTypes(): void { $json = '{"name": "vendor/package", "description": "description", "require": {"a": ["b"]} }'; - $this->assertEquals([ + self::assertEquals([ ['property' => 'require.a', 'message' => 'Array value found, but a string is required', 'constraint' => 'type'], ], $this->check($json)); } @@ -64,31 +64,31 @@ class ComposerSchemaTest extends TestCase ]; $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "" }'; - $this->assertEquals($expectedError, $this->check($json), 'empty string'); + self::assertEquals($expectedError, $this->check($json), 'empty string'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "dummy" }'; - $this->assertEquals($expectedError, $this->check($json), 'dummy'); + self::assertEquals($expectedError, $this->check($json), 'dummy'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "devz" }'; - $this->assertEquals($expectedError, $this->check($json), 'devz'); + self::assertEquals($expectedError, $this->check($json), 'devz'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "dev" }'; - $this->assertTrue($this->check($json), 'dev'); + self::assertTrue($this->check($json), 'dev'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "alpha" }'; - $this->assertTrue($this->check($json), 'alpha'); + self::assertTrue($this->check($json), 'alpha'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "beta" }'; - $this->assertTrue($this->check($json), 'beta'); + self::assertTrue($this->check($json), 'beta'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "rc" }'; - $this->assertTrue($this->check($json), 'rc lowercase'); + self::assertTrue($this->check($json), 'rc lowercase'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "RC" }'; - $this->assertTrue($this->check($json), 'rc uppercase'); + self::assertTrue($this->check($json), 'rc uppercase'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "stable" }'; - $this->assertTrue($this->check($json), 'stable'); + self::assertTrue($this->check($json), 'stable'); } /** diff --git a/tests/Composer/Test/Json/JsonFileTest.php b/tests/Composer/Test/Json/JsonFileTest.php index 74b124ec3..ed7623613 100644 --- a/tests/Composer/Test/Json/JsonFileTest.php +++ b/tests/Composer/Test/Json/JsonFileTest.php @@ -110,15 +110,15 @@ class JsonFileTest extends TestCase $json->validateSchema(); $this->fail('Expected exception to be thrown (strict)'); } catch (JsonValidationException $e) { - $this->assertEquals($expectedMessage, $e->getMessage()); - $this->assertContains($expectedError, $e->getErrors()); + self::assertEquals($expectedMessage, $e->getMessage()); + self::assertContains($expectedError, $e->getErrors()); } try { $json->validateSchema(JsonFile::LAX_SCHEMA); $this->fail('Expected exception to be thrown (lax)'); } catch (JsonValidationException $e) { - $this->assertEquals($expectedMessage, $e->getMessage()); - $this->assertContains($expectedError, $e->getErrors()); + self::assertEquals($expectedMessage, $e->getMessage()); + self::assertContains($expectedError, $e->getErrors()); } unlink($file); } @@ -132,8 +132,8 @@ class JsonFileTest extends TestCase $json->validateSchema(); $this->fail('Expected exception to be thrown (strict)'); } catch (JsonValidationException $e) { - $this->assertEquals(sprintf('"%s" does not match the expected JSON schema', $file), $e->getMessage()); - $this->assertEquals(['The property foo is not defined and the definition does not allow additional properties'], $e->getErrors()); + self::assertEquals(sprintf('"%s" does not match the expected JSON schema', $file), $e->getMessage()); + self::assertEquals(['The property foo is not defined and the definition does not allow additional properties'], $e->getErrors()); } $json->validateSchema(JsonFile::LAX_SCHEMA); unlink($file); @@ -151,10 +151,10 @@ class JsonFileTest extends TestCase $json->validateSchema(); $this->fail('Expected exception to be thrown (strict)'); } catch (JsonValidationException $e) { - $this->assertEquals($expectedMessage, $e->getMessage()); + self::assertEquals($expectedMessage, $e->getMessage()); $errors = $e->getErrors(); - $this->assertContains('name : The property name is required', $errors); - $this->assertContains('description : The property description is required', $errors); + self::assertContains('name : The property name is required', $errors); + self::assertContains('description : The property description is required', $errors); } $json->validateSchema(JsonFile::LAX_SCHEMA); @@ -163,8 +163,8 @@ class JsonFileTest extends TestCase $json->validateSchema(); $this->fail('Expected exception to be thrown (strict)'); } catch (JsonValidationException $e) { - $this->assertEquals($expectedMessage, $e->getMessage()); - $this->assertEquals(['description : The property description is required'], $e->getErrors()); + self::assertEquals($expectedMessage, $e->getMessage()); + self::assertEquals(['description : The property description is required'], $e->getErrors()); } $json->validateSchema(JsonFile::LAX_SCHEMA); @@ -173,8 +173,8 @@ class JsonFileTest extends TestCase $json->validateSchema(); $this->fail('Expected exception to be thrown (strict)'); } catch (JsonValidationException $e) { - $this->assertEquals($expectedMessage, $e->getMessage()); - $this->assertEquals(['name : The property name is required'], $e->getErrors()); + self::assertEquals($expectedMessage, $e->getMessage()); + self::assertEquals(['name : The property name is required'], $e->getErrors()); } $json->validateSchema(JsonFile::LAX_SCHEMA); @@ -183,10 +183,10 @@ class JsonFileTest extends TestCase $json->validateSchema(); $this->fail('Expected exception to be thrown (strict)'); } catch (JsonValidationException $e) { - $this->assertEquals($expectedMessage, $e->getMessage()); + self::assertEquals($expectedMessage, $e->getMessage()); $errors = $e->getErrors(); - $this->assertContains('name : The property name is required', $errors); - $this->assertContains('description : The property description is required', $errors); + self::assertContains('name : The property name is required', $errors); + self::assertContains('description : The property description is required', $errors); } $json->validateSchema(JsonFile::LAX_SCHEMA); @@ -195,10 +195,10 @@ class JsonFileTest extends TestCase $json->validateSchema(); $this->fail('Expected exception to be thrown (strict)'); } catch (JsonValidationException $e) { - $this->assertEquals($expectedMessage, $e->getMessage()); + self::assertEquals($expectedMessage, $e->getMessage()); $errors = $e->getErrors(); - $this->assertContains('name : The property name is required', $errors); - $this->assertContains('description : The property description is required', $errors); + self::assertContains('name : The property name is required', $errors); + self::assertContains('description : The property description is required', $errors); } $json->validateSchema(JsonFile::LAX_SCHEMA); @@ -252,8 +252,8 @@ class JsonFileTest extends TestCase JsonFile::validateJsonSchema('COMPOSER_AUTH', $json, JsonFile::AUTH_SCHEMA); $this->fail('Expected exception to be thrown'); } catch (JsonValidationException $e) { - $this->assertEquals($expectedMessage, $e->getMessage()); - $this->assertSame([$expectedError], $e->getErrors()); + self::assertEquals($expectedMessage, $e->getMessage()); + self::assertSame([$expectedError], $e->getErrors()); } } @@ -282,7 +282,7 @@ class JsonFileTest extends TestCase $json = '{ "name": "composer/composer" }'; - $this->assertJsonFormat($json, $data); + self::assertJsonFormat($json, $data); } public function testTrailingBackslash(): void @@ -291,7 +291,7 @@ class JsonFileTest extends TestCase $json = '{ "Metadata\\\\": "src/" }'; - $this->assertJsonFormat($json, $data); + self::assertJsonFormat($json, $data); } public function testFormatEmptyArray(): void @@ -301,7 +301,7 @@ class JsonFileTest extends TestCase "test": [], "test2": {} }'; - $this->assertJsonFormat($json, $data); + self::assertJsonFormat($json, $data); } public function testEscape(): void @@ -311,7 +311,7 @@ class JsonFileTest extends TestCase "Metadata\\\\\\"": "src/" }'; - $this->assertJsonFormat($json, $data); + self::assertJsonFormat($json, $data); } public function testUnicode(): void @@ -321,35 +321,35 @@ class JsonFileTest extends TestCase "Žluťoučký \" kůň": "úpěl ďábelské ódy za €" }'; - $this->assertJsonFormat($json, $data); + self::assertJsonFormat($json, $data); } public function testOnlyUnicode(): void { $data = "\\/ƌ"; - $this->assertJsonFormat('"\\\\\\/ƌ"', $data, JSON_UNESCAPED_UNICODE); + self::assertJsonFormat('"\\\\\\/ƌ"', $data, JSON_UNESCAPED_UNICODE); } public function testEscapedSlashes(): void { $data = "\\/foo"; - $this->assertJsonFormat('"\\\\\\/foo"', $data, 0); + self::assertJsonFormat('"\\\\\\/foo"', $data, 0); } public function testEscapedBackslashes(): void { $data = "a\\b"; - $this->assertJsonFormat('"a\\\\b"', $data, 0); + self::assertJsonFormat('"a\\\\b"', $data, 0); } public function testEscapedUnicode(): void { $data = "ƌ"; - $this->assertJsonFormat('"\\u018c"', $data, 0); + self::assertJsonFormat('"\\u018c"', $data, 0); } public function testDoubleEscapedUnicode(): void @@ -361,7 +361,7 @@ class JsonFileTest extends TestCase $decodedData = json_decode($doubleEncodedData, true); $doubleData = json_decode($decodedData['t'], true); - $this->assertEquals($data, $doubleData); + self::assertEquals($data, $doubleData); } public function testPreserveIndentationAfterRead(): void @@ -393,7 +393,7 @@ class JsonFileTest extends TestCase $result = JsonFile::parseJson($json); $this->fail(sprintf("Parsing should have failed but didn't.\nExpected:\n\"%s\"\nFor:\n\"%s\"\nGot:\n\"%s\"", $text, $json, var_export($result, true))); } catch (ParsingException $e) { - $this->assertStringContainsString($text, $e->getMessage()); + self::assertStringContainsString($text, $e->getMessage()); } } @@ -406,9 +406,9 @@ class JsonFileTest extends TestCase $json = str_replace("\r", '', $json); if (null === $options) { - $this->assertEquals($json, $file->encode($data)); + self::assertEquals($json, $file->encode($data)); } else { - $this->assertEquals($json, $file->encode($data, $options)); + self::assertEquals($json, $file->encode($data, $options)); } } } diff --git a/tests/Composer/Test/Json/JsonFormatterTest.php b/tests/Composer/Test/Json/JsonFormatterTest.php index 9bc38c673..44ca8d2cf 100644 --- a/tests/Composer/Test/Json/JsonFormatterTest.php +++ b/tests/Composer/Test/Json/JsonFormatterTest.php @@ -30,7 +30,7 @@ class JsonFormatterTest extends TestCase $data = '"' . $backslash . $backslash . $backslash . 'u0119"'; $expected = '"' . $backslash . $backslash . 'ę"'; /** @phpstan-ignore staticMethod.dynamicCall, staticMethod.deprecatedClass */ - $this->assertEquals($expected, JsonFormatter::format($data, true, true)); + self::assertEquals($expected, JsonFormatter::format($data, true, true)); } /** @@ -45,6 +45,6 @@ class JsonFormatterTest extends TestCase $escaped = '"\ud83d\ude00"'; /** @phpstan-ignore staticMethod.dynamicCall, staticMethod.deprecatedClass */ - $this->assertEquals($escaped, JsonFormatter::format($escaped, true, true)); + self::assertEquals($escaped, JsonFormatter::format($escaped, true, true)); } } diff --git a/tests/Composer/Test/Json/JsonManipulatorTest.php b/tests/Composer/Test/Json/JsonManipulatorTest.php index 1d27069bd..9cce7845c 100644 --- a/tests/Composer/Test/Json/JsonManipulatorTest.php +++ b/tests/Composer/Test/Json/JsonManipulatorTest.php @@ -12,6 +12,7 @@ namespace Composer\Test\Json; +use Composer\Json\JsonFile; use Composer\Json\JsonManipulator; use Composer\Test\TestCase; @@ -23,8 +24,8 @@ class JsonManipulatorTest extends TestCase public function testAddLink(string $json, string $type, string $package, string $constraint, string $expected): void { $manipulator = new JsonManipulator($json); - $this->assertTrue($manipulator->addLink($type, $package, $constraint)); - $this->assertEquals($expected, $manipulator->getContents()); + self::assertTrue($manipulator->addLink($type, $package, $constraint)); + self::assertEquals($expected, $manipulator->getContents()); } public static function linkProvider(): array @@ -1293,8 +1294,8 @@ class JsonManipulatorTest extends TestCase public function testAddLinkAndSortPackages(string $json, string $type, string $package, string $constraint, bool $sortPackages, string $expected): void { $manipulator = new JsonManipulator($json); - $this->assertTrue($manipulator->addLink($type, $package, $constraint, $sortPackages)); - $this->assertEquals($expected, $manipulator->getContents()); + self::assertTrue($manipulator->addLink($type, $package, $constraint, $sortPackages)); + self::assertEquals($expected, $manipulator->getContents()); } public static function providerAddLinkAndSortPackages(): array @@ -1374,9 +1375,9 @@ class JsonManipulatorTest extends TestCase { $manipulator = new JsonManipulator($json); - $this->assertEquals($expected, $manipulator->removeSubNode('repositories', $name)); + self::assertEquals($expected, $manipulator->removeSubNode('repositories', $name)); if (null !== $expectedContent) { - $this->assertEquals($expectedContent, $manipulator->getContents()); + self::assertEquals($expectedContent, $manipulator->getContents()); } } @@ -1696,9 +1697,9 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->removeSubNode('require', 'package/c')); - $this->assertTrue($manipulator->removeSubNode('require-dev', 'package/d')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeSubNode('require', 'package/c')); + self::assertTrue($manipulator->removeSubNode('require-dev', 'package/d')); + self::assertEquals('{ "repositories": [ { "package": { @@ -1727,8 +1728,8 @@ class JsonManipulatorTest extends TestCase "test": {"0": "foo"} }'); - $this->assertTrue($manipulator->removeSubNode('test', '0')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeSubNode('test', '0')); + self::assertEquals('{ "test": { } } @@ -1743,8 +1744,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->removeConfigSetting('preferred-install.foo/*')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeConfigSetting('preferred-install.foo/*')); + self::assertEquals('{ "config": { "preferred-install": { } @@ -1777,9 +1778,9 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addSubNode('require', 'package/c', '*')); - $this->assertTrue($manipulator->addSubNode('require-dev', 'package/e', '*')); - $this->assertEquals('{ + self::assertTrue($manipulator->addSubNode('require', 'package/c', '*')); + self::assertTrue($manipulator->addSubNode('require-dev', 'package/e', '*')); + self::assertEquals('{ "repositories": [ { "package": { @@ -1825,8 +1826,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addProperty('extra.foo-bar', true)); - $this->assertEquals('{ + self::assertTrue($manipulator->addProperty('extra.foo-bar', true)); + self::assertEquals('{ "repositories": [ { "type": "package", @@ -1867,8 +1868,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('preferred-install.my-organization/stable-package', 'dist')); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('preferred-install.my-organization/stable-package', 'dist')); + self::assertEquals('{ "repositories": [ { "type": "package", @@ -1911,8 +1912,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addProperty('suggest.new-package', 'new-description')); - $this->assertEquals('{ + self::assertTrue($manipulator->addProperty('suggest.new-package', 'new-description')); + self::assertEquals('{ "repositories": [ { "type": "package", @@ -1939,8 +1940,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addRepository('bar', ['type' => 'composer'])); - $this->assertEquals('{ + self::assertTrue($manipulator->addRepository('bar', ['type' => 'composer'])); + self::assertEquals('{ "repositories": { "bar": { "type": "composer" @@ -1956,8 +1957,8 @@ class JsonManipulatorTest extends TestCase \t\"a\": \"b\" }"); - $this->assertTrue($manipulator->addRepository('bar2', ['type' => 'composer'])); - $this->assertEquals("{ + self::assertTrue($manipulator->addRepository('bar2', ['type' => 'composer'])); + self::assertEquals("{ \t\"a\": \"b\", \t\"repositories\": { \t\t\"bar2\": { @@ -1979,8 +1980,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addRepository('bar', ['type' => 'composer'], true)); - $this->assertEquals('{ + self::assertTrue($manipulator->addRepository('bar', ['type' => 'composer'], true)); + self::assertEquals('{ "repositories": { "foo": { "type": "vcs", @@ -2005,8 +2006,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addRepository('bar', ['type' => 'composer'], false)); - $this->assertEquals('{ + self::assertTrue($manipulator->addRepository('bar', ['type' => 'composer'], false)); + self::assertEquals('{ "repositories": { "bar": { "type": "composer" @@ -2031,8 +2032,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addRepository('baz', ['type' => 'composer'])); - $this->assertEquals('{ + self::assertTrue($manipulator->addRepository('baz', ['type' => 'composer'])); + self::assertEquals('{ "repositories": { "baz": { "type": "composer" @@ -2049,9 +2050,9 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('test', 'a\b')); - $this->assertTrue($manipulator->addConfigSetting('test2', "a\nb\fa")); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('test', 'a\b')); + self::assertTrue($manipulator->addConfigSetting('test2', "a\nb\fa")); + self::assertEquals('{ "config": { "test": "a\\\\b", "test2": "a\nb\fa" @@ -2065,8 +2066,8 @@ class JsonManipulatorTest extends TestCase $manipulator = new JsonManipulator('{ }'); - $this->assertTrue($manipulator->addConfigSetting('foo.bar', 'baz')); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('foo.bar', 'baz')); + self::assertEquals('{ "config": { "foo": { "bar": "baz" @@ -2084,8 +2085,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('bar', 'baz')); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('bar', 'baz')); + self::assertEquals('{ "config": { "foo": "bar", "bar": "baz" @@ -2103,8 +2104,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('foo', 'zomg')); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('foo', 'zomg')); + self::assertEquals('{ "config": { "foo": "zomg", "bar": "baz" @@ -2121,8 +2122,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('foo', 50)); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('foo', 50)); + self::assertEquals('{ "config": { "foo": 50 } @@ -2141,8 +2142,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('github-protocols', ['https', 'http'])); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('github-protocols', ['https', 'http'])); + self::assertEquals('{ "config": { "github-oauth": { "github.com": "foo" @@ -2152,8 +2153,8 @@ class JsonManipulatorTest extends TestCase } ', $manipulator->getContents()); - $this->assertTrue($manipulator->addConfigSetting('github-oauth', ['github.com' => 'bar', 'alt.example.org' => 'baz'])); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('github-oauth', ['github.com' => 'bar', 'alt.example.org' => 'baz'])); + self::assertEquals('{ "config": { "github-oauth": { "github.com": "bar", @@ -2172,8 +2173,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); + self::assertEquals('{ "config": { "github-oauth": { "bar": "baz" @@ -2193,10 +2194,10 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); - $this->assertTrue($manipulator->addConfigSetting('github-oauth2.a.bar', 'baz2')); - $this->assertTrue($manipulator->addConfigSetting('github-oauth3.b', 'c')); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); + self::assertTrue($manipulator->addConfigSetting('github-oauth2.a.bar', 'baz2')); + self::assertTrue($manipulator->addConfigSetting('github-oauth3.b', 'c')); + self::assertEquals('{ "config": { "github-oauth": { "bar": "baz" @@ -2222,8 +2223,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); - $this->assertEquals('{ + self::assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); + self::assertEquals('{ "config": { "github-oauth": { "github.com": "foo", @@ -2242,8 +2243,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addSubNode('github-oauth', 'bar', 'baz')); - $this->assertEquals('{ + self::assertTrue($manipulator->addSubNode('github-oauth', 'bar', 'baz')); + self::assertEquals('{ "github-oauth": { "github.com": "foo", "bar": "baz" @@ -2263,8 +2264,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->removeConfigSetting('github-oauth.bar')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeConfigSetting('github-oauth.bar')); + self::assertEquals('{ "config": { "github-oauth": { "github.com": "foo" @@ -2286,8 +2287,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->removeConfigSetting('github-oauth.bar')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeConfigSetting('github-oauth.bar')); + self::assertEquals('{ "config": { "foo": "bar", "github-oauth": { @@ -2304,8 +2305,8 @@ class JsonManipulatorTest extends TestCase "foo": "bar" }'); - $this->assertTrue($manipulator->addMainKey('bar', 'baz')); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('bar', 'baz')); + self::assertEquals('{ "foo": "bar", "bar": "baz" } @@ -2318,8 +2319,8 @@ class JsonManipulatorTest extends TestCase "foo": "bar" }'); - $this->assertTrue($manipulator->addMainKey('bar', '$1baz')); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('bar', '$1baz')); + self::assertEquals('{ "foo": "bar", "bar": "$1baz" } @@ -2330,8 +2331,8 @@ class JsonManipulatorTest extends TestCase { $manipulator = new JsonManipulator('{}'); - $this->assertTrue($manipulator->addMainKey('foo', '$1bar')); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('foo', '$1bar')); + self::assertEquals('{ "foo": "$1bar" } ', $manipulator->getContents()); @@ -2343,8 +2344,8 @@ class JsonManipulatorTest extends TestCase "foo": "bar" }'); - $this->assertTrue($manipulator->addMainKey('foo', 'baz')); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('foo', 'baz')); + self::assertEquals('{ "foo": "baz" } ', $manipulator->getContents()); @@ -2361,9 +2362,9 @@ class JsonManipulatorTest extends TestCase "baz": "bar" }'); - $this->assertTrue($manipulator->addMainKey('foo', 'baz')); - $this->assertTrue($manipulator->addMainKey('baz', 'quux')); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('foo', 'baz')); + self::assertTrue($manipulator->addMainKey('baz', 'quux')); + self::assertEquals('{ "a": { "foo": "bar", "baz": "qux" @@ -2385,8 +2386,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addMainKey('require-dev', ['foo' => 'qux'])); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('require-dev', ['foo' => 'qux'])); + self::assertEquals('{ "require": { "php": "5.*" }, @@ -2403,8 +2404,8 @@ class JsonManipulatorTest extends TestCase "foo": "bar" }'); - $this->assertTrue($manipulator->addMainKey('foo', '$1bar')); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('foo', '$1bar')); + self::assertEquals('{ "foo": "$1bar" } ', $manipulator->getContents()); @@ -2436,8 +2437,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->removeMainKey('repositories')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeMainKey('repositories')); + self::assertEquals('{ "require": { "package/a": "*", "package/b": "*", @@ -2450,8 +2451,8 @@ class JsonManipulatorTest extends TestCase } ', $manipulator->getContents()); - $this->assertTrue($manipulator->removeMainKey('foo')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeMainKey('foo')); + self::assertEquals('{ "require": { "package/a": "*", "package/b": "*", @@ -2463,9 +2464,9 @@ class JsonManipulatorTest extends TestCase } ', $manipulator->getContents()); - $this->assertTrue($manipulator->removeMainKey('require')); - $this->assertTrue($manipulator->removeMainKey('require-dev')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeMainKey('require')); + self::assertTrue($manipulator->removeMainKey('require-dev')); + self::assertEquals('{ } ', $manipulator->getContents()); } @@ -2485,8 +2486,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->removeMainKeyIfEmpty('repositories')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeMainKeyIfEmpty('repositories')); + self::assertEquals('{ "require": { "package/a": "*", "package/b": "*", @@ -2498,10 +2499,10 @@ class JsonManipulatorTest extends TestCase } ', $manipulator->getContents()); - $this->assertTrue($manipulator->removeMainKeyIfEmpty('foo')); - $this->assertTrue($manipulator->removeMainKeyIfEmpty('require')); - $this->assertTrue($manipulator->removeMainKeyIfEmpty('require-dev')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeMainKeyIfEmpty('foo')); + self::assertTrue($manipulator->removeMainKeyIfEmpty('require')); + self::assertTrue($manipulator->removeMainKeyIfEmpty('require-dev')); + self::assertEquals('{ "require": { "package/a": "*", "package/b": "*", @@ -2521,11 +2522,11 @@ class JsonManipulatorTest extends TestCase $manipulator->removeMainKey('bar'); - $expected = json_encode([ + $expected = JsonFile::encode([ 'foo' => 9000, ]); - $this->assertJsonStringEqualsJsonString($expected, $manipulator->getContents()); + self::assertJsonStringEqualsJsonString($expected, $manipulator->getContents()); } public function testIndentDetection(): void @@ -2537,8 +2538,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addMainKey('require-dev', ['foo' => 'qux'])); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('require-dev', ['foo' => 'qux'])); + self::assertEquals('{ "require": { "php": "5.*" @@ -2558,9 +2559,9 @@ class JsonManipulatorTest extends TestCase } } '); - $this->assertTrue($manipulator->addMainKey('homepage', 'http...')); - $this->assertTrue($manipulator->addMainKey('license', 'mit')); - $this->assertEquals('{ + self::assertTrue($manipulator->addMainKey('homepage', 'http...')); + self::assertTrue($manipulator->addMainKey('license', 'mit')); + self::assertEquals('{ "require": { "package/a": "*" }, @@ -2569,9 +2570,9 @@ class JsonManipulatorTest extends TestCase } ', $manipulator->getContents()); - $this->assertTrue($manipulator->removeMainKey('homepage')); - $this->assertTrue($manipulator->removeMainKey('license')); - $this->assertEquals('{ + self::assertTrue($manipulator->removeMainKey('homepage')); + self::assertTrue($manipulator->removeMainKey('license')); + self::assertEquals('{ "require": { "package/a": "*" } @@ -2588,8 +2589,8 @@ class JsonManipulatorTest extends TestCase } }'); - $this->assertTrue($manipulator->addLink('require', 'foo/baz', '^1.0')); - $this->assertEquals('{ + self::assertTrue($manipulator->addLink('require', 'foo/baz', '^1.0')); + self::assertEquals('{ "description": "Some U\u00F1icode", "require": { "foo/bar": "^1.0", @@ -3251,8 +3252,8 @@ class JsonManipulatorTest extends TestCase "prefer-stable": true }'); - $this->assertTrue($manipulator->addSubNode('config', 'platform-check', false)); - $this->assertEquals('{ + self::assertTrue($manipulator->addSubNode('config', 'platform-check', false)); + self::assertEquals('{ "name": "leoloso/pop", "require": { "php": "^7.4|^8.0", diff --git a/tests/Composer/Test/Json/JsonValidationExceptionTest.php b/tests/Composer/Test/Json/JsonValidationExceptionTest.php index 69a446341..672f99364 100644 --- a/tests/Composer/Test/Json/JsonValidationExceptionTest.php +++ b/tests/Composer/Test/Json/JsonValidationExceptionTest.php @@ -25,14 +25,14 @@ class JsonValidationExceptionTest extends TestCase public function testGetErrors(string $message, array $errors, string $expectedMessage, array $expectedErrors): void { $object = new JsonValidationException($message, $errors); - $this->assertSame($expectedMessage, $object->getMessage()); - $this->assertSame($expectedErrors, $object->getErrors()); + self::assertSame($expectedMessage, $object->getMessage()); + self::assertSame($expectedErrors, $object->getErrors()); } public function testGetErrorsWhenNoErrorsProvided(): void { $object = new JsonValidationException('test message'); - $this->assertEquals([], $object->getErrors()); + self::assertEquals([], $object->getErrors()); } public static function errorProvider(): array diff --git a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php index ad5cb98af..377a820c2 100644 --- a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php @@ -116,7 +116,7 @@ class ArchivableFilesFinderTest extends TestCase $this->finder = new ArchivableFilesFinder($this->sources, $excludes); - $this->assertArchivableFiles([ + self::assertArchivableFiles([ '/!important!.txt', '/!important_too!.txt', '/#weirdfile', @@ -191,7 +191,7 @@ class ArchivableFilesFinderTest extends TestCase $this->finder = new ArchivableFilesFinder($this->sources, []); - $this->assertArchivableFiles($this->getArchivedFiles( + self::assertArchivableFiles($this->getArchivedFiles( 'git init && '. 'git config user.email "you@example.com" && '. 'git config user.name "Your Name" && '. @@ -212,7 +212,7 @@ class ArchivableFilesFinderTest extends TestCase $this->finder = new ArchivableFilesFinder($this->sources, $excludes, true); - $this->assertArchivableFiles([ + self::assertArchivableFiles([ '/!important!.txt', '/!important_too!.txt', '/#weirdfile', @@ -306,6 +306,6 @@ class ArchivableFilesFinderTest extends TestCase { $actualFiles = $this->getArchivableFiles(); - $this->assertEquals($expectedFiles, $actualFiles); + self::assertEquals($expectedFiles, $actualFiles); } } diff --git a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php index ca07aede4..e75e49a70 100644 --- a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php @@ -69,10 +69,10 @@ class ArchiveManagerTest extends ArchiverTestCase $this->manager->archive($package, 'tar', $this->targetDir); $target = $this->getTargetName($package, 'tar'); - $this->assertFileExists($target); + self::assertFileExists($target); $tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package); - $this->assertFileDoesNotExist($tmppath); + self::assertFileDoesNotExist($tmppath); unlink($target); } @@ -91,10 +91,10 @@ class ArchiveManagerTest extends ArchiverTestCase $target = $this->targetDir . '/' . $fileName . '.tar'; - $this->assertFileExists($target); + self::assertFileExists($target); $tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package); - $this->assertFileDoesNotExist($tmppath); + self::assertFileDoesNotExist($tmppath); unlink($target); } diff --git a/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php b/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php index 0f28bd35d..56134e23a 100644 --- a/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php +++ b/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php @@ -26,7 +26,7 @@ class GitExcludeFilterTest extends TestCase { $filter = new GitExcludeFilter('/'); - $this->assertEquals($expected, $filter->parseGitAttributesLine($ignore)); + self::assertEquals($expected, $filter->parseGitAttributesLine($ignore)); } public static function providePatterns(): array diff --git a/tests/Composer/Test/Package/Archiver/PharArchiverTest.php b/tests/Composer/Test/Package/Archiver/PharArchiverTest.php index 1d6e68e2e..cfe203004 100644 --- a/tests/Composer/Test/Package/Archiver/PharArchiverTest.php +++ b/tests/Composer/Test/Package/Archiver/PharArchiverTest.php @@ -27,7 +27,7 @@ class PharArchiverTest extends ArchiverTestCase // Test archive $archiver = new PharArchiver(); $archiver->archive($package->getSourceUrl(), $target, 'tar', ['foo/bar', 'baz', '!/foo/bar/baz']); - $this->assertFileExists($target); + self::assertFileExists($target); $this->filesystem->removeDirectory(dirname($target)); } @@ -42,7 +42,7 @@ class PharArchiverTest extends ArchiverTestCase // Test archive $archiver = new PharArchiver(); $archiver->archive($package->getSourceUrl(), $target, 'zip'); - $this->assertFileExists($target); + self::assertFileExists($target); $this->filesystem->removeDirectory(dirname($target)); } diff --git a/tests/Composer/Test/Package/BasePackageTest.php b/tests/Composer/Test/Package/BasePackageTest.php index 324bda08f..ae4084417 100644 --- a/tests/Composer/Test/Package/BasePackageTest.php +++ b/tests/Composer/Test/Package/BasePackageTest.php @@ -54,7 +54,7 @@ class BasePackageTest extends TestCase $package->expects($this->once())->method('getPrettyVersion')->will($this->returnValue('PrettyVersion')); $package->expects($this->any())->method('getSourceReference')->will($this->returnValue($sourceReference)); - $this->assertSame($expected, $package->getFullPrettyVersion($truncate)); + self::assertSame($expected, $package->getFullPrettyVersion($truncate)); } public static function provideFormattedVersions(): array @@ -93,7 +93,7 @@ class BasePackageTest extends TestCase { $regexp = BasePackage::packageNamesToRegexp($packageNames, $wrap); - $this->assertSame($expectedRegexp, $regexp); + self::assertSame($expectedRegexp, $regexp); } /** diff --git a/tests/Composer/Test/Package/CompletePackageTest.php b/tests/Composer/Test/Package/CompletePackageTest.php index 17dce9fa1..6f7fe5f2b 100644 --- a/tests/Composer/Test/Package/CompletePackageTest.php +++ b/tests/Composer/Test/Package/CompletePackageTest.php @@ -42,7 +42,7 @@ class CompletePackageTest extends TestCase $versionParser = new VersionParser(); $normVersion = $versionParser->normalize($version); $package = new Package($name, $normVersion, $version); - $this->assertEquals(strtolower($name), $package->getName()); + self::assertEquals(strtolower($name), $package->getName()); } /** @@ -53,8 +53,8 @@ class CompletePackageTest extends TestCase $versionParser = new VersionParser(); $normVersion = $versionParser->normalize($version); $package = new Package($name, $normVersion, $version); - $this->assertEquals($version, $package->getPrettyVersion()); - $this->assertEquals($normVersion, $package->getVersion()); + self::assertEquals($version, $package->getPrettyVersion()); + self::assertEquals($normVersion, $package->getVersion()); } /** @@ -65,34 +65,34 @@ class CompletePackageTest extends TestCase $versionParser = new VersionParser(); $normVersion = $versionParser->normalize($version); $package = new Package($name, $normVersion, $version); - $this->assertEquals(strtolower($name).'-'.$normVersion, (string) $package); + self::assertEquals(strtolower($name).'-'.$normVersion, (string) $package); } public function testGetTargetDir(): void { $package = new Package('a', '1.0.0.0', '1.0'); - $this->assertNull($package->getTargetDir()); + self::assertNull($package->getTargetDir()); $package->setTargetDir('./../foo/'); - $this->assertEquals('foo/', $package->getTargetDir()); + self::assertEquals('foo/', $package->getTargetDir()); $package->setTargetDir('foo/../../../bar/'); - $this->assertEquals('foo/bar/', $package->getTargetDir()); + self::assertEquals('foo/bar/', $package->getTargetDir()); $package->setTargetDir('../..'); - $this->assertEquals('', $package->getTargetDir()); + self::assertEquals('', $package->getTargetDir()); $package->setTargetDir('..'); - $this->assertEquals('', $package->getTargetDir()); + self::assertEquals('', $package->getTargetDir()); $package->setTargetDir('/..'); - $this->assertEquals('', $package->getTargetDir()); + self::assertEquals('', $package->getTargetDir()); $package->setTargetDir('/foo/..'); - $this->assertEquals('foo/', $package->getTargetDir()); + self::assertEquals('foo/', $package->getTargetDir()); $package->setTargetDir('/foo/..//bar'); - $this->assertEquals('foo/bar', $package->getTargetDir()); + self::assertEquals('foo/bar', $package->getTargetDir()); } } diff --git a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php index ca885243a..95a638820 100644 --- a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php +++ b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php @@ -32,7 +32,7 @@ class ArrayDumperTest extends TestCase public function testRequiredInformation(): void { $config = $this->dumper->dump(self::getPackage()); - $this->assertEquals( + self::assertEquals( [ 'name' => 'dummy/pkg', 'version' => '1.0.0', @@ -49,7 +49,7 @@ class ArrayDumperTest extends TestCase $package->setMinimumStability('dev'); $config = $this->dumper->dump($package); - $this->assertSame('dev', $config['minimum-stability']); + self::assertSame('dev', $config['minimum-stability']); } public function testDumpAbandoned(): void @@ -58,7 +58,7 @@ class ArrayDumperTest extends TestCase $package->setAbandoned(true); $config = $this->dumper->dump($package); - $this->assertTrue($config['abandoned']); + self::assertTrue($config['abandoned']); } public function testDumpAbandonedReplacement(): void @@ -67,7 +67,7 @@ class ArrayDumperTest extends TestCase $package->setAbandoned('foo/bar'); $config = $this->dumper->dump($package); - $this->assertSame('foo/bar', $config['abandoned']); + self::assertSame('foo/bar', $config['abandoned']); } /** @@ -81,12 +81,12 @@ class ArrayDumperTest extends TestCase { $package = self::getRootPackage(); - // @phpstan-ignore method.dynamicName, ternary.shortNotAllowed - $package->{'set'.ucfirst($method ?: $key)}($value); + // @phpstan-ignore method.dynamicName + $package->{'set'.ucfirst($method ?? $key)}($value); $config = $this->dumper->dump($package); - $this->assertSame($expectedValue ?: $value, $config[$key]); + self::assertSame($expectedValue ?: $value, $config[$key]); } public static function provideKeys(): array diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index 31f4fdf49..09602fca0 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -42,7 +42,7 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); $replaces = $package->getReplaces(); - $this->assertEquals('== 1.2.3.4', (string) $replaces['foo']->getConstraint()); + self::assertEquals('== 1.2.3.4', (string) $replaces['foo']->getConstraint()); } public function testTypeDefault(): void @@ -53,7 +53,7 @@ class ArrayLoaderTest extends TestCase ]; $package = $this->loader->load($config); - $this->assertEquals('library', $package->getType()); + self::assertEquals('library', $package->getType()); $config = [ 'name' => 'A', @@ -62,7 +62,7 @@ class ArrayLoaderTest extends TestCase ]; $package = $this->loader->load($config); - $this->assertEquals('foo', $package->getType()); + self::assertEquals('foo', $package->getType()); } public function testNormalizedVersionOptimization(): void @@ -73,7 +73,7 @@ class ArrayLoaderTest extends TestCase ]; $package = $this->loader->load($config); - $this->assertEquals('1.2.3.0', $package->getVersion()); + self::assertEquals('1.2.3.0', $package->getVersion()); $config = [ 'name' => 'A', @@ -82,7 +82,7 @@ class ArrayLoaderTest extends TestCase ]; $package = $this->loader->load($config); - $this->assertEquals('1.2.3.4', $package->getVersion()); + self::assertEquals('1.2.3.4', $package->getVersion()); } public static function parseDumpProvider(): array @@ -161,7 +161,7 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); $dumper = new ArrayDumper; $expectedConfig = $this->fixConfigWhenLoadConfigIsFalse($config); - $this->assertEquals($expectedConfig, $dumper->dump($package)); + self::assertEquals($expectedConfig, $dumper->dump($package)); } /** @@ -175,7 +175,7 @@ class ArrayLoaderTest extends TestCase $package = $loader->load($config); $dumper = new ArrayDumper; $expectedConfig = $config; - $this->assertEquals($expectedConfig, $dumper->dump($package)); + self::assertEquals($expectedConfig, $dumper->dump($package)); } /** @@ -189,7 +189,7 @@ class ArrayLoaderTest extends TestCase $package = $loader->load($config); $dumper = new ArrayDumper; $expectedConfig = $this->fixConfigWhenLoadConfigIsFalse($config); - $this->assertEquals($expectedConfig, $dumper->dump($package)); + self::assertEquals($expectedConfig, $dumper->dump($package)); } public function testPackageWithBranchAlias(): void @@ -202,8 +202,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\AliasPackage', $package); - $this->assertEquals('1.0.x-dev', $package->getPrettyVersion()); + self::assertInstanceOf('Composer\Package\AliasPackage', $package); + self::assertEquals('1.0.x-dev', $package->getPrettyVersion()); $config = [ 'name' => 'A', @@ -213,8 +213,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\AliasPackage', $package); - $this->assertEquals('1.0.x-dev', $package->getPrettyVersion()); + self::assertInstanceOf('Composer\Package\AliasPackage', $package); + self::assertEquals('1.0.x-dev', $package->getPrettyVersion()); $config = [ 'name' => 'B', @@ -224,8 +224,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\AliasPackage', $package); - $this->assertEquals('4.0.x-dev', $package->getPrettyVersion()); + self::assertInstanceOf('Composer\Package\AliasPackage', $package); + self::assertEquals('4.0.x-dev', $package->getPrettyVersion()); $config = [ 'name' => 'B', @@ -235,8 +235,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\AliasPackage', $package); - $this->assertEquals('4.0.x-dev', $package->getPrettyVersion()); + self::assertInstanceOf('Composer\Package\AliasPackage', $package); + self::assertEquals('4.0.x-dev', $package->getPrettyVersion()); $config = [ 'name' => 'C', @@ -246,8 +246,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\CompletePackage', $package); - $this->assertEquals('4.x-dev', $package->getPrettyVersion()); + self::assertInstanceOf('Composer\Package\CompletePackage', $package); + self::assertEquals('4.x-dev', $package->getPrettyVersion()); } public function testPackageAliasingWithoutBranchAlias(): void @@ -261,8 +261,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\AliasPackage', $package); - $this->assertEquals(VersionParser::DEFAULT_BRANCH_ALIAS, $package->getPrettyVersion()); + self::assertInstanceOf('Composer\Package\AliasPackage', $package); + self::assertEquals(VersionParser::DEFAULT_BRANCH_ALIAS, $package->getPrettyVersion()); // non-default branch gets no alias even if non-numeric $config = [ @@ -273,8 +273,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\CompletePackage', $package); - $this->assertEquals('dev-main', $package->getPrettyVersion()); + self::assertInstanceOf('Composer\Package\CompletePackage', $package); + self::assertEquals('dev-main', $package->getPrettyVersion()); // default branch gets no alias if already numeric $config = [ @@ -285,8 +285,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\CompletePackage', $package); - $this->assertEquals('2.9999999.9999999.9999999-dev', $package->getVersion()); + self::assertInstanceOf('Composer\Package\CompletePackage', $package); + self::assertEquals('2.9999999.9999999.9999999-dev', $package->getVersion()); // default branch gets no alias if already numeric, with v prefix $config = [ @@ -297,8 +297,8 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); - $this->assertInstanceOf('Composer\Package\CompletePackage', $package); - $this->assertEquals('2.9999999.9999999.9999999-dev', $package->getVersion()); + self::assertInstanceOf('Composer\Package\CompletePackage', $package); + self::assertEquals('2.9999999.9999999.9999999-dev', $package->getVersion()); } public function testAbandoned(): void @@ -310,8 +310,8 @@ class ArrayLoaderTest extends TestCase ]; $package = $this->loader->load($config); - $this->assertTrue($package->isAbandoned()); - $this->assertEquals('foo/bar', $package->getReplacementPackage()); + self::assertTrue($package->isAbandoned()); + self::assertEquals('foo/bar', $package->getReplacementPackage()); } public function testNotAbandoned(): void @@ -322,7 +322,7 @@ class ArrayLoaderTest extends TestCase ]; $package = $this->loader->load($config); - $this->assertFalse($package->isAbandoned()); + self::assertFalse($package->isAbandoned()); } public static function providePluginApiVersions(): array @@ -353,23 +353,23 @@ class ArrayLoaderTest extends TestCase { $links = $this->loader->parseLinks('Plugin', '9.9.9', Link::TYPE_REQUIRE, ['composer-plugin-api' => $apiVersion]); - $this->assertArrayHasKey('composer-plugin-api', $links); - $this->assertSame($apiVersion, $links['composer-plugin-api']->getConstraint()->getPrettyString()); + self::assertArrayHasKey('composer-plugin-api', $links); + self::assertSame($apiVersion, $links['composer-plugin-api']->getConstraint()->getPrettyString()); } public function testPluginApiVersionDoesSupportSelfVersion(): void { $links = $this->loader->parseLinks('Plugin', '6.6.6', Link::TYPE_REQUIRE, ['composer-plugin-api' => 'self.version']); - $this->assertArrayHasKey('composer-plugin-api', $links); - $this->assertSame('6.6.6', $links['composer-plugin-api']->getConstraint()->getPrettyString()); + self::assertArrayHasKey('composer-plugin-api', $links); + self::assertSame('6.6.6', $links['composer-plugin-api']->getConstraint()->getPrettyString()); } public function testParseLinksIntegerTarget(): void { $links = $this->loader->parseLinks('Plugin', '9.9.9', Link::TYPE_REQUIRE, ['1' => 'dev-main']); - $this->assertArrayHasKey('1', $links); + self::assertArrayHasKey('1', $links); } public function testNoneStringVersion(): void @@ -380,7 +380,7 @@ class ArrayLoaderTest extends TestCase ]; $package = $this->loader->load($config); - $this->assertSame('1', $package->getPrettyVersion()); + self::assertSame('1', $package->getPrettyVersion()); } public function testNoneStringSourceDistReference(): void @@ -401,8 +401,8 @@ class ArrayLoaderTest extends TestCase ]; $package = $this->loader->load($config); - $this->assertSame('2019', $package->getSourceReference()); - $this->assertSame('2019', $package->getDistReference()); + self::assertSame('2019', $package->getSourceReference()); + self::assertSame('2019', $package->getDistReference()); } public function testBranchAliasIntegerIndex(): void @@ -421,7 +421,7 @@ class ArrayLoaderTest extends TestCase ], ]; - $this->assertNull($this->loader->getBranchAlias($config)); + self::assertNull($this->loader->getBranchAlias($config)); } public function testPackageLinksRequire(): void @@ -435,8 +435,8 @@ class ArrayLoaderTest extends TestCase ); $package = $this->loader->load($config); - $this->assertArrayHasKey('foo/bar', $package->getRequires()); - $this->assertSame('1.0', $package->getRequires()['foo/bar']->getConstraint()->getPrettyString()); + self::assertArrayHasKey('foo/bar', $package->getRequires()); + self::assertSame('1.0', $package->getRequires()['foo/bar']->getConstraint()->getPrettyString()); } public function testPackageLinksRequireInvalid(): void @@ -452,7 +452,7 @@ class ArrayLoaderTest extends TestCase ); $package = $this->loader->load($config); - $this->assertCount(0, $package->getRequires()); + self::assertCount(0, $package->getRequires()); } public function testPackageLinksReplace(): void @@ -466,8 +466,8 @@ class ArrayLoaderTest extends TestCase ); $package = $this->loader->load($config); - $this->assertArrayHasKey('coyote/package', $package->getReplaces()); - $this->assertSame('dev-1', $package->getReplaces()['coyote/package']->getConstraint()->getPrettyString()); + self::assertArrayHasKey('coyote/package', $package->getReplaces()); + self::assertSame('dev-1', $package->getReplaces()['coyote/package']->getConstraint()->getPrettyString()); } public function testPackageLinksReplaceInvalid(): void @@ -479,7 +479,7 @@ class ArrayLoaderTest extends TestCase ); $package = $this->loader->load($config); - $this->assertCount(0, $package->getReplaces()); + self::assertCount(0, $package->getReplaces()); } public function testSupportStringValue(): void @@ -491,6 +491,6 @@ class ArrayLoaderTest extends TestCase ); $package = $this->loader->load($config); - $this->assertSame([], $package->getSupport()); + self::assertSame([], $package->getSupport()); } } diff --git a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php index 28684e56e..a66377f9e 100644 --- a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php @@ -62,8 +62,8 @@ class RootPackageLoaderTest extends TestCase 'minimum-stability' => 'alpha', ]); - $this->assertEquals('alpha', $package->getMinimumStability()); - $this->assertEquals([ + self::assertEquals('alpha', $package->getMinimumStability()); + self::assertEquals([ 'bar/baz' => BasePackage::STABILITY_DEV, 'qux/quux' => BasePackage::STABILITY_RC, 'zux/complex' => BasePackage::STABILITY_DEV, @@ -88,8 +88,8 @@ class RootPackageLoaderTest extends TestCase $package = $loader->load([]); - $this->assertEquals("1.0.0.0", $package->getVersion()); - $this->assertEquals(RootPackage::DEFAULT_PRETTY_VERSION, $package->getPrettyVersion()); + self::assertEquals("1.0.0.0", $package->getVersion()); + self::assertEquals(RootPackage::DEFAULT_PRETTY_VERSION, $package->getPrettyVersion()); } public function testPrettyVersionForRootPackageInVersionBranch(): void @@ -110,7 +110,7 @@ class RootPackageLoaderTest extends TestCase $loader = new RootPackageLoader($manager, $config, null, $versionGuesser); $package = $loader->load([]); - $this->assertEquals('3.0-dev', $package->getPrettyVersion()); + self::assertEquals('3.0-dev', $package->getPrettyVersion()); } public function testFeatureBranchPrettyVersion(): void @@ -138,7 +138,7 @@ class RootPackageLoaderTest extends TestCase $loader = new RootPackageLoader($manager, $config, null, new VersionGuesser($config, $process, new VersionParser())); $package = $loader->load(['require' => ['foo/bar' => 'self.version']]); - $this->assertEquals("dev-master", $package->getPrettyVersion()); + self::assertEquals("dev-master", $package->getPrettyVersion()); } public function testNonFeatureBranchPrettyVersion(): void @@ -165,6 +165,6 @@ class RootPackageLoaderTest extends TestCase $loader = new RootPackageLoader($manager, $config, null, new VersionGuesser($config, $process, new VersionParser())); $package = $loader->load(['require' => ['foo/bar' => 'self.version'], "non-feature-branches" => ["latest-.*"]]); - $this->assertEquals("dev-latest-production", $package->getPrettyVersion()); + self::assertEquals("dev-latest-production", $package->getPrettyVersion()); } } diff --git a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php index 40f05894e..9b70911ee 100644 --- a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php @@ -224,7 +224,7 @@ class ValidatingArrayLoaderTest extends TestCase $errors = $e->getErrors(); sort($expectedErrors); sort($errors); - $this->assertEquals($expectedErrors, $errors); + self::assertEquals($expectedErrors, $errors); } } @@ -243,7 +243,7 @@ class ValidatingArrayLoaderTest extends TestCase $warnings = $loader->getWarnings(); sort($expectedWarnings); sort($warnings); - $this->assertEquals($expectedWarnings, $warnings); + self::assertEquals($expectedWarnings, $warnings); } /** @@ -255,7 +255,7 @@ class ValidatingArrayLoaderTest extends TestCase public function testLoadSkipsWarningDataWhenIgnoringErrors(array $config, array $expectedWarnings, bool $mustCheck = true): void { if (!$mustCheck) { - $this->assertTrue(true); + self::assertTrue(true); // @phpstan-ignore staticMethod.alreadyNarrowedType return; } diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index 7d3233b45..fc0178cf2 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -39,7 +39,7 @@ class LockerTest extends TestCase ->method('read') ->will($this->returnValue(['packages' => []])); - $this->assertTrue($locker->isLocked()); + self::assertTrue($locker->isLocked()); } public function testGetNotLockedPackages(): void @@ -81,8 +81,8 @@ class LockerTest extends TestCase ])); $repo = $locker->getLockedRepository(); - $this->assertNotNull($repo->findPackage('pkg1', '1.0.0-beta')); - $this->assertNotNull($repo->findPackage('pkg2', '0.1.10')); + self::assertNotNull($repo->findPackage('pkg1', '1.0.0-beta')); + self::assertNotNull($repo->findPackage('pkg2', '0.1.10')); } public function testSetLockData(): void @@ -156,7 +156,7 @@ class LockerTest extends TestCase ->method('read') ->will($this->returnValue(['hash' => md5($jsonContent)])); - $this->assertTrue($locker->isFresh()); + self::assertTrue($locker->isFresh()); } public function testIsFreshFalse(): void @@ -171,7 +171,7 @@ class LockerTest extends TestCase ->method('read') ->will($this->returnValue(['hash' => $this->getJsonContent(['name' => 'test2'])])); - $this->assertFalse($locker->isFresh()); + self::assertFalse($locker->isFresh()); } public function testIsFreshWithContentHash(): void @@ -187,7 +187,7 @@ class LockerTest extends TestCase ->method('read') ->will($this->returnValue(['hash' => md5($jsonContent . ' '), 'content-hash' => md5($jsonContent)])); - $this->assertTrue($locker->isFresh()); + self::assertTrue($locker->isFresh()); } public function testIsFreshWithContentHashAndNoHash(): void @@ -203,7 +203,7 @@ class LockerTest extends TestCase ->method('read') ->will($this->returnValue(['content-hash' => md5($jsonContent)])); - $this->assertTrue($locker->isFresh()); + self::assertTrue($locker->isFresh()); } public function testIsFreshFalseWithContentHash(): void @@ -220,7 +220,7 @@ class LockerTest extends TestCase ->method('read') ->will($this->returnValue(['hash' => $differentHash, 'content-hash' => $differentHash])); - $this->assertFalse($locker->isFresh()); + self::assertFalse($locker->isFresh()); } /** diff --git a/tests/Composer/Test/Package/RootAliasPackageTest.php b/tests/Composer/Test/Package/RootAliasPackageTest.php index 8f71a3bd0..b475719fd 100644 --- a/tests/Composer/Test/Package/RootAliasPackageTest.php +++ b/tests/Composer/Test/Package/RootAliasPackageTest.php @@ -31,9 +31,9 @@ class RootAliasPackageTest extends TestCase ->with($this->equalTo($links)); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getRequires()); + self::assertEmpty($alias->getRequires()); $alias->setRequires($links); - $this->assertNotEmpty($alias->getRequires()); + self::assertNotEmpty($alias->getRequires()); } public function testUpdateDevRequires(): void @@ -46,9 +46,9 @@ class RootAliasPackageTest extends TestCase ->with($this->equalTo($links)); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getDevRequires()); + self::assertEmpty($alias->getDevRequires()); $alias->setDevRequires($links); - $this->assertNotEmpty($alias->getDevRequires()); + self::assertNotEmpty($alias->getDevRequires()); } public function testUpdateConflicts(): void @@ -61,9 +61,9 @@ class RootAliasPackageTest extends TestCase ->with($this->equalTo($links)); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getConflicts()); + self::assertEmpty($alias->getConflicts()); $alias->setConflicts($links); - $this->assertNotEmpty($alias->getConflicts()); + self::assertNotEmpty($alias->getConflicts()); } public function testUpdateProvides(): void @@ -76,9 +76,9 @@ class RootAliasPackageTest extends TestCase ->with($this->equalTo($links)); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getProvides()); + self::assertEmpty($alias->getProvides()); $alias->setProvides($links); - $this->assertNotEmpty($alias->getProvides()); + self::assertNotEmpty($alias->getProvides()); } public function testUpdateReplaces(): void @@ -91,9 +91,9 @@ class RootAliasPackageTest extends TestCase ->with($this->equalTo($links)); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); - $this->assertEmpty($alias->getReplaces()); + self::assertEmpty($alias->getReplaces()); $alias->setReplaces($links); - $this->assertNotEmpty($alias->getReplaces()); + self::assertNotEmpty($alias->getReplaces()); } /** diff --git a/tests/Composer/Test/Package/Version/VersionBumperTest.php b/tests/Composer/Test/Package/Version/VersionBumperTest.php index a146c2884..ba5874378 100644 --- a/tests/Composer/Test/Package/Version/VersionBumperTest.php +++ b/tests/Composer/Test/Package/Version/VersionBumperTest.php @@ -37,7 +37,7 @@ class VersionBumperTest extends TestCase $newConstraint = $versionBumper->bumpRequirement($versionParser->parseConstraints($requirement), $package); // assert that the recommended version is what we expect - $this->assertSame($expectedRequirement, $newConstraint); + self::assertSame($expectedRequirement, $newConstraint); } public static function provideBumpRequirementTests(): Generator diff --git a/tests/Composer/Test/Package/Version/VersionGuesserTest.php b/tests/Composer/Test/Package/Version/VersionGuesserTest.php index 2e59afe6a..676ef2420 100644 --- a/tests/Composer/Test/Package/Version/VersionGuesserTest.php +++ b/tests/Composer/Test/Package/Version/VersionGuesserTest.php @@ -50,9 +50,9 @@ class VersionGuesserTest extends TestCase $versionArray = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionArray); - $this->assertEquals("dev-".$branch, $versionArray['version']); - $this->assertEquals("dev-".$branch, $versionArray['pretty_version']); - $this->assertEmpty($versionArray['commit']); + self::assertEquals("dev-".$branch, $versionArray['version']); + self::assertEquals("dev-".$branch, $versionArray['pretty_version']); + self::assertEmpty($versionArray['commit']); } public function testGuessVersionReturnsData(): void @@ -74,11 +74,11 @@ class VersionGuesserTest extends TestCase $versionArray = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionArray); - $this->assertEquals("dev-master", $versionArray['version']); - $this->assertEquals("dev-master", $versionArray['pretty_version']); - $this->assertArrayNotHasKey('feature_version', $versionArray); - $this->assertArrayNotHasKey('feature_pretty_version', $versionArray); - $this->assertEquals($commitHash, $versionArray['commit']); + self::assertEquals("dev-master", $versionArray['version']); + self::assertEquals("dev-master", $versionArray['pretty_version']); + self::assertArrayNotHasKey('feature_version', $versionArray); + self::assertArrayNotHasKey('feature_pretty_version', $versionArray); + self::assertEquals($commitHash, $versionArray['commit']); } public function testGuessVersionDoesNotSeeCustomDefaultBranchAsNonFeatureBranch(): void @@ -101,8 +101,8 @@ class VersionGuesserTest extends TestCase $versionArray = $guesser->guessVersion(['version' => 'self.version'], 'dummy/path'); self::assertIsArray($versionArray); - $this->assertEquals("dev-current", $versionArray['version']); - $this->assertEquals($anotherCommitHash, $versionArray['commit']); + self::assertEquals("dev-current", $versionArray['version']); + self::assertEquals($anotherCommitHash, $versionArray['commit']); } public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNaming(): void @@ -128,11 +128,11 @@ class VersionGuesserTest extends TestCase $versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['arbitrary']], 'dummy/path'); self::assertIsArray($versionArray); - $this->assertEquals("dev-arbitrary", $versionArray['version']); - $this->assertEquals($anotherCommitHash, $versionArray['commit']); + self::assertEquals("dev-arbitrary", $versionArray['version']); + self::assertEquals($anotherCommitHash, $versionArray['commit']); self::assertArrayHasKey('feature_version', $versionArray); - $this->assertEquals("dev-feature", $versionArray['feature_version']); - $this->assertEquals("dev-feature", $versionArray['feature_pretty_version']); + self::assertEquals("dev-feature", $versionArray['feature_version']); + self::assertEquals("dev-feature", $versionArray['feature_pretty_version']); } public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNamingRegex(): void @@ -158,11 +158,11 @@ class VersionGuesserTest extends TestCase $versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['latest-.*']], 'dummy/path'); self::assertIsArray($versionArray); - $this->assertEquals("dev-latest-testing", $versionArray['version']); - $this->assertEquals($anotherCommitHash, $versionArray['commit']); + self::assertEquals("dev-latest-testing", $versionArray['version']); + self::assertEquals($anotherCommitHash, $versionArray['commit']); self::assertArrayHasKey('feature_version', $versionArray); - $this->assertEquals("dev-feature", $versionArray['feature_version']); - $this->assertEquals("dev-feature", $versionArray['feature_pretty_version']); + self::assertEquals("dev-feature", $versionArray['feature_version']); + self::assertEquals("dev-feature", $versionArray['feature_pretty_version']); } public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNamingWhenOnNonFeatureBranch(): void @@ -184,10 +184,10 @@ class VersionGuesserTest extends TestCase $versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['latest-.*']], 'dummy/path'); self::assertIsArray($versionArray); - $this->assertEquals("dev-latest-testing", $versionArray['version']); - $this->assertEquals($commitHash, $versionArray['commit']); - $this->assertArrayNotHasKey('feature_version', $versionArray); - $this->assertArrayNotHasKey('feature_pretty_version', $versionArray); + self::assertEquals("dev-latest-testing", $versionArray['version']); + self::assertEquals($commitHash, $versionArray['commit']); + self::assertArrayNotHasKey('feature_version', $versionArray); + self::assertArrayNotHasKey('feature_pretty_version', $versionArray); } public function testDetachedHeadBecomesDevHash(): void @@ -209,7 +209,7 @@ class VersionGuesserTest extends TestCase $versionData = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionData); - $this->assertEquals("dev-$commitHash", $versionData['version']); + self::assertEquals("dev-$commitHash", $versionData['version']); } public function testDetachedFetchHeadBecomesDevHashGit2(): void @@ -231,7 +231,7 @@ class VersionGuesserTest extends TestCase $versionData = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionData); - $this->assertEquals("dev-$commitHash", $versionData['version']); + self::assertEquals("dev-$commitHash", $versionData['version']); } public function testDetachedCommitHeadBecomesDevHashGit2(): void @@ -253,7 +253,7 @@ class VersionGuesserTest extends TestCase $versionData = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionData); - $this->assertEquals("dev-$commitHash", $versionData['version']); + self::assertEquals("dev-$commitHash", $versionData['version']); } public function testTagBecomesVersion(): void @@ -276,7 +276,7 @@ class VersionGuesserTest extends TestCase $versionData = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionData); - $this->assertEquals("2.0.5.0-alpha2", $versionData['version']); + self::assertEquals("2.0.5.0-alpha2", $versionData['version']); } public function testTagBecomesPrettyVersion(): void @@ -299,8 +299,8 @@ class VersionGuesserTest extends TestCase $versionData = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionData); - $this->assertEquals('1.0.0.0', $versionData['version']); - $this->assertEquals('1.0.0', $versionData['pretty_version']); + self::assertEquals('1.0.0.0', $versionData['version']); + self::assertEquals('1.0.0', $versionData['pretty_version']); } public function testInvalidTagBecomesVersion(): void @@ -319,7 +319,7 @@ class VersionGuesserTest extends TestCase $versionData = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionData); - $this->assertEquals("dev-foo", $versionData['version']); + self::assertEquals("dev-foo", $versionData['version']); } public function testNumericBranchesShowNicely(): void @@ -338,8 +338,8 @@ class VersionGuesserTest extends TestCase $versionData = $guesser->guessVersion([], 'dummy/path'); self::assertIsArray($versionData); - $this->assertEquals("1.5.x-dev", $versionData['pretty_version']); - $this->assertEquals("1.5.9999999.9999999-dev", $versionData['version']); + self::assertEquals("1.5.x-dev", $versionData['pretty_version']); + self::assertEquals("1.5.9999999.9999999-dev", $versionData['version']); } public function testRemoteBranchesAreSelected(): void @@ -362,7 +362,7 @@ class VersionGuesserTest extends TestCase $guesser = new VersionGuesser($config, $process, new VersionParser()); $versionData = $guesser->guessVersion(['version' => 'self.version'], 'dummy/path'); self::assertIsArray($versionData); - $this->assertEquals("1.5.x-dev", $versionData['pretty_version']); - $this->assertEquals("1.5.9999999.9999999-dev", $versionData['version']); + self::assertEquals("1.5.x-dev", $versionData['pretty_version']); + self::assertEquals("1.5.9999999.9999999-dev", $versionData['version']); } } diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index c0db2142a..845b52dfe 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -27,7 +27,7 @@ class VersionParserTest extends TestCase { $versionParser = new VersionParser(); - $this->assertSame($result, $versionParser->parseNameVersionPairs($pairs)); + self::assertSame($result, $versionParser->parseNameVersionPairs($pairs)); } public static function provideParseNameVersionPairsData(): array @@ -46,7 +46,7 @@ class VersionParserTest extends TestCase */ public function testIsUpgrade(string $from, string $to, bool $expected): void { - $this->assertSame($expected, VersionParser::isUpgrade($from, $to)); + self::assertSame($expected, VersionParser::isUpgrade($from, $to)); } public static function provideIsUpgradeTests(): array diff --git a/tests/Composer/Test/Package/Version/VersionSelectorTest.php b/tests/Composer/Test/Package/Version/VersionSelectorTest.php index aec5cf86c..e4d508cd8 100644 --- a/tests/Composer/Test/Package/Version/VersionSelectorTest.php +++ b/tests/Composer/Test/Package/Version/VersionSelectorTest.php @@ -48,7 +48,7 @@ class VersionSelectorTest extends TestCase $best = $versionSelector->findBestCandidate($packageName); // 1.2.2 should be returned because it's the latest of the returned versions - $this->assertSame($package2, $best, 'Latest version should be 1.2.2'); + self::assertSame($package2, $best, 'Latest version should be 1.2.2'); } public function testLatestVersionIsReturnedThatMatchesPhpRequirements(): void @@ -77,12 +77,12 @@ class VersionSelectorTest extends TestCase $io = new BufferIO(); $best = $versionSelector->findBestCandidate($packageName, null, 'stable', null, 0, $io); - $this->assertSame((string) $package1, (string) $best, 'Latest version supporting php 5.5 should be returned (1.0.0)'); + self::assertSame((string) $package1, (string) $best, 'Latest version supporting php 5.5 should be returned (1.0.0)'); self::assertSame("Cannot use foo/bar's latest version 2.1.0 as it requires php >=5.6 which is not satisfied by your platform.".PHP_EOL, $io->getOutput()); $io = new BufferIO('', StreamOutput::VERBOSITY_VERBOSE); $best = $versionSelector->findBestCandidate($packageName, null, 'stable', null, 0, $io); - $this->assertSame((string) $package1, (string) $best, 'Latest version supporting php 5.5 should be returned (1.0.0)'); + self::assertSame((string) $package1, (string) $best, 'Latest version supporting php 5.5 should be returned (1.0.0)'); self::assertSame( "Cannot use foo/bar's latest version 2.1.0 as it requires php >=5.6 which is not satisfied by your platform.".PHP_EOL ."Cannot use foo/bar 2.0.0 as it requires php >=5.6 which is not satisfied by your platform.".PHP_EOL, @@ -90,7 +90,7 @@ class VersionSelectorTest extends TestCase ); $best = $versionSelector->findBestCandidate($packageName, null, 'stable', PlatformRequirementFilterFactory::ignoreAll()); - $this->assertSame((string) $package3, (string) $best, 'Latest version should be returned when ignoring platform reqs (2.1.0)'); + self::assertSame((string) $package3, (string) $best, 'Latest version should be returned when ignoring platform reqs (2.1.0)'); } public function testLatestVersionIsReturnedThatMatchesExtRequirements(): void @@ -114,9 +114,9 @@ class VersionSelectorTest extends TestCase ->will($this->returnValue($packages)); $best = $versionSelector->findBestCandidate($packageName); - $this->assertSame($package1, $best, 'Latest version supporting ext-zip 5.3.0 should be returned (1.0.0)'); + self::assertSame($package1, $best, 'Latest version supporting ext-zip 5.3.0 should be returned (1.0.0)'); $best = $versionSelector->findBestCandidate($packageName, null, 'stable', PlatformRequirementFilterFactory::ignoreAll()); - $this->assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (2.0.0)'); + self::assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (2.0.0)'); } public function testLatestVersionIsReturnedThatMatchesPlatformExt(): void @@ -139,9 +139,9 @@ class VersionSelectorTest extends TestCase ->will($this->returnValue($packages)); $best = $versionSelector->findBestCandidate($packageName); - $this->assertSame($package1, $best, 'Latest version not requiring ext-barfoo should be returned (1.0.0)'); + self::assertSame($package1, $best, 'Latest version not requiring ext-barfoo should be returned (1.0.0)'); $best = $versionSelector->findBestCandidate($packageName, null, 'stable', PlatformRequirementFilterFactory::ignoreAll()); - $this->assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (2.0.0)'); + self::assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (2.0.0)'); } public function testLatestVersionIsReturnedThatMatchesComposerRequirements(): void @@ -165,9 +165,9 @@ class VersionSelectorTest extends TestCase ->will($this->returnValue($packages)); $best = $versionSelector->findBestCandidate($packageName); - $this->assertSame($package1, $best, 'Latest version supporting composer 1 should be returned (1.0.0)'); + self::assertSame($package1, $best, 'Latest version supporting composer 1 should be returned (1.0.0)'); $best = $versionSelector->findBestCandidate($packageName, null, 'stable', PlatformRequirementFilterFactory::ignoreAll()); - $this->assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (1.1.0)'); + self::assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (1.1.0)'); } public function testMostStableVersionIsReturned(): void @@ -187,7 +187,7 @@ class VersionSelectorTest extends TestCase $versionSelector = new VersionSelector($repositorySet); $best = $versionSelector->findBestCandidate($packageName); - $this->assertSame($package1, $best, 'Latest most stable version should be returned (1.0.0)'); + self::assertSame($package1, $best, 'Latest most stable version should be returned (1.0.0)'); } public function testMostStableVersionIsReturnedRegardlessOfOrder(): void @@ -209,10 +209,10 @@ class VersionSelectorTest extends TestCase $versionSelector = new VersionSelector($repositorySet); $best = $versionSelector->findBestCandidate($packageName); - $this->assertSame($package2, $best, 'Expecting 2.0.0-beta3, cause beta is more stable than dev'); + self::assertSame($package2, $best, 'Expecting 2.0.0-beta3, cause beta is more stable than dev'); $best = $versionSelector->findBestCandidate($packageName); - $this->assertSame($package2, $best, 'Expecting 2.0.0-beta3, cause beta is more stable than dev'); + self::assertSame($package2, $best, 'Expecting 2.0.0-beta3, cause beta is more stable than dev'); } public function testHighestVersionIsReturned(): void @@ -232,7 +232,7 @@ class VersionSelectorTest extends TestCase $versionSelector = new VersionSelector($repositorySet); $best = $versionSelector->findBestCandidate($packageName, null, 'dev'); - $this->assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)'); + self::assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)'); } public function testHighestVersionMatchingStabilityIsReturned(): void @@ -253,7 +253,7 @@ class VersionSelectorTest extends TestCase $versionSelector = new VersionSelector($repositorySet); $best = $versionSelector->findBestCandidate($packageName, null, 'beta'); - $this->assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)'); + self::assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)'); } public function testMostStableUnstableVersionIsReturned(): void @@ -273,7 +273,7 @@ class VersionSelectorTest extends TestCase $versionSelector = new VersionSelector($repositorySet); $best = $versionSelector->findBestCandidate($packageName, null, 'stable'); - $this->assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)'); + self::assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)'); } public function testDefaultBranchAliasIsNeverReturned(): void @@ -294,7 +294,7 @@ class VersionSelectorTest extends TestCase $versionSelector = new VersionSelector($repositorySet); $best = $versionSelector->findBestCandidate($packageName, null, 'dev'); - $this->assertSame($package2, $best, 'Latest version should be returned (dev-main)'); + self::assertSame($package2, $best, 'Latest version should be returned (dev-main)'); } public function testFalseReturnedOnNoPackages(): void @@ -306,7 +306,7 @@ class VersionSelectorTest extends TestCase $versionSelector = new VersionSelector($repositorySet); $best = $versionSelector->findBestCandidate('foobaz'); - $this->assertFalse($best, 'No versions are available returns false'); + self::assertFalse($best, 'No versions are available returns false'); } /** @@ -327,7 +327,7 @@ class VersionSelectorTest extends TestCase $recommended = $versionSelector->findRecommendedRequireVersion($package); // assert that the recommended version is what we expect - $this->assertSame($expectedVersion, $recommended); + self::assertSame($expectedVersion, $recommended); } public static function provideRecommendedRequireVersionPackages(): array diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index ecaa615a2..ba2402a19 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -160,8 +160,8 @@ class PluginInstallerTest extends TestCase $installer->install($this->repository, $this->packages[0]); $plugins = $this->pm->getPlugins(); - $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound - $this->assertEquals( + self::assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore property.notFound + self::assertEquals( 'activate v1'.PHP_EOL, $this->io->getOutput() ); @@ -182,11 +182,11 @@ class PluginInstallerTest extends TestCase $installer->install($this->repository, $this->packages[0]); $plugins = $this->pm->getPlugins(); - $this->assertEquals( + self::assertEquals( 'activate v1'.PHP_EOL, $this->io->getOutput() ); - $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound + self::assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore property.notFound } public function testInstallMultiplePlugins(): void @@ -201,11 +201,11 @@ class PluginInstallerTest extends TestCase $installer->install($this->repository, $this->packages[3]); $plugins = $this->pm->getPlugins(); - $this->assertEquals('plugin1', $plugins[0]->name); // @phpstan-ignore staticMethod.dynamicCall, property.notFound - $this->assertEquals('installer-v4', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound - $this->assertEquals('plugin2', $plugins[1]->name); // @phpstan-ignore staticMethod.dynamicCall, property.notFound - $this->assertEquals('installer-v4', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound - $this->assertEquals('activate v4-plugin1'.PHP_EOL.'activate v4-plugin2'.PHP_EOL, $this->io->getOutput()); + self::assertEquals('plugin1', $plugins[0]->name); // @phpstan-ignore property.notFound + self::assertEquals('installer-v4', $plugins[0]->version); // @phpstan-ignore property.notFound + self::assertEquals('plugin2', $plugins[1]->name); // @phpstan-ignore property.notFound + self::assertEquals('installer-v4', $plugins[1]->version); // @phpstan-ignore property.notFound + self::assertEquals('activate v4-plugin1'.PHP_EOL.'activate v4-plugin2'.PHP_EOL, $this->io->getOutput()); } public function testUpgradeWithNewClassName(): void @@ -224,9 +224,9 @@ class PluginInstallerTest extends TestCase $installer->update($this->repository, $this->packages[0], $this->packages[1]); $plugins = $this->pm->getPlugins(); - $this->assertCount(1, $plugins); - $this->assertEquals('installer-v2', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound - $this->assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'activate v2'.PHP_EOL, $this->io->getOutput()); + self::assertCount(1, $plugins); + self::assertEquals('installer-v2', $plugins[1]->version); // @phpstan-ignore property.notFound + self::assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'activate v2'.PHP_EOL, $this->io->getOutput()); } public function testUninstall(): void @@ -245,8 +245,8 @@ class PluginInstallerTest extends TestCase $installer->uninstall($this->repository, $this->packages[0]); $plugins = $this->pm->getPlugins(); - $this->assertCount(0, $plugins); - $this->assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'uninstall v1'.PHP_EOL, $this->io->getOutput()); + self::assertCount(0, $plugins); + self::assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'uninstall v1'.PHP_EOL, $this->io->getOutput()); } public function testUpgradeWithSameClassName(): void @@ -265,8 +265,8 @@ class PluginInstallerTest extends TestCase $installer->update($this->repository, $this->packages[1], $this->packages[2]); $plugins = $this->pm->getPlugins(); - $this->assertEquals('installer-v3', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound - $this->assertEquals('activate v2'.PHP_EOL.'deactivate v2'.PHP_EOL.'activate v3'.PHP_EOL, $this->io->getOutput()); + self::assertEquals('installer-v3', $plugins[1]->version); // @phpstan-ignore property.notFound + self::assertEquals('activate v2'.PHP_EOL.'deactivate v2'.PHP_EOL.'activate v3'.PHP_EOL, $this->io->getOutput()); } public function testRegisterPluginOnlyOneTime(): void @@ -282,9 +282,9 @@ class PluginInstallerTest extends TestCase $installer->install($this->repository, clone $this->packages[0]); $plugins = $this->pm->getPlugins(); - $this->assertCount(1, $plugins); - $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound - $this->assertEquals('activate v1'.PHP_EOL, $this->io->getOutput()); + self::assertCount(1, $plugins); + self::assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore property.notFound + self::assertEquals('activate v1'.PHP_EOL, $this->io->getOutput()); } /** @@ -325,16 +325,16 @@ class PluginInstallerTest extends TestCase $starVersionPlugin = [$this->packages[4]]; $this->setPluginApiVersionWithPlugins('1.0.0', $starVersionPlugin); - $this->assertCount(1, $this->pm->getPlugins()); + self::assertCount(1, $this->pm->getPlugins()); $this->setPluginApiVersionWithPlugins('1.9.9', $starVersionPlugin); - $this->assertCount(1, $this->pm->getPlugins()); + self::assertCount(1, $this->pm->getPlugins()); $this->setPluginApiVersionWithPlugins('2.0.0-dev', $starVersionPlugin); - $this->assertCount(1, $this->pm->getPlugins()); + self::assertCount(1, $this->pm->getPlugins()); $this->setPluginApiVersionWithPlugins('100.0.0-stable', $starVersionPlugin); - $this->assertCount(1, $this->pm->getPlugins()); + self::assertCount(1, $this->pm->getPlugins()); } public function testPluginConstraintWorksOnlyWithCertainAPIVersion(): void @@ -342,16 +342,16 @@ class PluginInstallerTest extends TestCase $pluginWithApiConstraint = [$this->packages[5]]; $this->setPluginApiVersionWithPlugins('1.0.0', $pluginWithApiConstraint); - $this->assertCount(0, $this->pm->getPlugins()); + self::assertCount(0, $this->pm->getPlugins()); $this->setPluginApiVersionWithPlugins('1.1.9', $pluginWithApiConstraint); - $this->assertCount(0, $this->pm->getPlugins()); + self::assertCount(0, $this->pm->getPlugins()); $this->setPluginApiVersionWithPlugins('1.2.0', $pluginWithApiConstraint); - $this->assertCount(1, $this->pm->getPlugins()); + self::assertCount(1, $this->pm->getPlugins()); $this->setPluginApiVersionWithPlugins('1.9.9', $pluginWithApiConstraint); - $this->assertCount(1, $this->pm->getPlugins()); + self::assertCount(1, $this->pm->getPlugins()); } public function testPluginRangeConstraintsWorkOnlyWithCertainAPIVersion(): void @@ -359,13 +359,13 @@ class PluginInstallerTest extends TestCase $pluginWithApiConstraint = [$this->packages[6]]; $this->setPluginApiVersionWithPlugins('1.0.0', $pluginWithApiConstraint); - $this->assertCount(0, $this->pm->getPlugins()); + self::assertCount(0, $this->pm->getPlugins()); $this->setPluginApiVersionWithPlugins('3.0.0', $pluginWithApiConstraint); - $this->assertCount(1, $this->pm->getPlugins()); + self::assertCount(1, $this->pm->getPlugins()); $this->setPluginApiVersionWithPlugins('5.5.0', $pluginWithApiConstraint); - $this->assertCount(0, $this->pm->getPlugins()); + self::assertCount(0, $this->pm->getPlugins()); } public function testCommandProviderCapability(): void @@ -379,19 +379,19 @@ class PluginInstallerTest extends TestCase /** @var \Composer\Plugin\Capability\CommandProvider[] $caps */ $caps = $this->pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', ['composer' => $this->composer, 'io' => $this->io]); - $this->assertCount(1, $caps); - $this->assertInstanceOf('Composer\Plugin\Capability\CommandProvider', $caps[0]); + self::assertCount(1, $caps); + self::assertInstanceOf('Composer\Plugin\Capability\CommandProvider', $caps[0]); $commands = $caps[0]->getCommands(); - $this->assertCount(1, $commands); - $this->assertInstanceOf('Composer\Command\BaseCommand', $commands[0]); + self::assertCount(1, $commands); + self::assertInstanceOf('Composer\Command\BaseCommand', $commands[0]); } public function testIncapablePluginIsCorrectlyDetected(): void { $plugin = $this->getMockBuilder('Composer\Plugin\PluginInterface') ->getMock(); - $this->assertNull($this->pm->getPluginCapability($plugin, 'Fake\Ability')); + self::assertNull($this->pm->getPluginCapability($plugin, 'Fake\Ability')); } public function testCapabilityImplementsComposerPluginApiClassAndIsConstructedWithArgs(): void @@ -411,9 +411,9 @@ class PluginInstallerTest extends TestCase /** @var \Composer\Test\Plugin\Mock\Capability $capability */ $capability = $this->pm->getPluginCapability($plugin, $capabilityApi, ['a' => 1, 'b' => 2]); - $this->assertInstanceOf($capabilityApi, $capability); - $this->assertInstanceOf($capabilityImplementation, $capability); - $this->assertSame(['a' => 1, 'b' => 2, 'plugin' => $plugin], $capability->args); + self::assertInstanceOf($capabilityApi, $capability); + self::assertInstanceOf($capabilityImplementation, $capability); + self::assertSame(['a' => 1, 'b' => 2, 'plugin' => $plugin], $capability->args); } /** @return mixed[] */ @@ -467,7 +467,7 @@ class PluginInstallerTest extends TestCase return []; })); - $this->assertNull($this->pm->getPluginCapability($plugin, $capabilityApi)); + self::assertNull($this->pm->getPluginCapability($plugin, $capabilityApi)); } /** @return mixed[] */ diff --git a/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php b/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php index 371f49597..bfad93083 100644 --- a/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php +++ b/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php @@ -63,7 +63,7 @@ class StrictConfirmationQuestionTest extends TestCase [$input, $dialog] = $this->createInput($question."\n"); $question = new StrictConfirmationQuestion('Do you like French fries?', $default); - $this->assertEquals($expected, $dialog->ask($input, $this->createOutputInterface(), $question), 'confirmation question should '.($expected ? 'pass' : 'cancel')); + self::assertEquals($expected, $dialog->ask($input, $this->createOutputInterface(), $question), 'confirmation question should '.($expected ? 'pass' : 'cancel')); } /** @@ -88,10 +88,10 @@ class StrictConfirmationQuestionTest extends TestCase $question = new StrictConfirmationQuestion('Do you like French fries?', false, '/^ja$/i', '/^nein$/i'); [$input, $dialog] = $this->createInput("ja\n"); - $this->assertTrue($dialog->ask($input, $this->createOutputInterface(), $question)); + self::assertTrue($dialog->ask($input, $this->createOutputInterface(), $question)); [$input, $dialog] = $this->createInput("nein\n"); - $this->assertFalse($dialog->ask($input, $this->createOutputInterface(), $question)); + self::assertFalse($dialog->ask($input, $this->createOutputInterface(), $question)); } /** @@ -100,7 +100,7 @@ class StrictConfirmationQuestionTest extends TestCase protected function getInputStream(string $input) { $stream = fopen('php://memory', 'r+', false); - $this->assertNotFalse($stream); + self::assertNotFalse($stream); fwrite($stream, $input); rewind($stream); diff --git a/tests/Composer/Test/Repository/ArrayRepositoryTest.php b/tests/Composer/Test/Repository/ArrayRepositoryTest.php index 95d56a867..a06fb648c 100644 --- a/tests/Composer/Test/Repository/ArrayRepositoryTest.php +++ b/tests/Composer/Test/Repository/ArrayRepositoryTest.php @@ -23,7 +23,7 @@ class ArrayRepositoryTest extends TestCase $repo = new ArrayRepository; $repo->addPackage(self::getPackage('foo', '1')); - $this->assertCount(1, $repo); + self::assertCount(1, $repo); } public function testRemovePackage(): void @@ -34,12 +34,12 @@ class ArrayRepositoryTest extends TestCase $repo->addPackage(self::getPackage('foo', '1')); $repo->addPackage($package); - $this->assertCount(2, $repo); + self::assertCount(2, $repo); $repo->removePackage(self::getPackage('foo', '1')); - $this->assertCount(1, $repo); - $this->assertEquals([$package], $repo->getPackages()); + self::assertCount(1, $repo); + self::assertEquals([$package], $repo->getPackages()); } public function testHasPackage(): void @@ -48,8 +48,8 @@ class ArrayRepositoryTest extends TestCase $repo->addPackage(self::getPackage('foo', '1')); $repo->addPackage(self::getPackage('bar', '2')); - $this->assertTrue($repo->hasPackage(self::getPackage('foo', '1'))); - $this->assertFalse($repo->hasPackage(self::getPackage('bar', '1'))); + self::assertTrue($repo->hasPackage(self::getPackage('foo', '1'))); + self::assertFalse($repo->hasPackage(self::getPackage('bar', '1'))); } public function testFindPackages(): void @@ -60,12 +60,12 @@ class ArrayRepositoryTest extends TestCase $repo->addPackage(self::getPackage('bar', '3')); $foo = $repo->findPackages('foo'); - $this->assertCount(1, $foo); - $this->assertEquals('foo', $foo[0]->getName()); + self::assertCount(1, $foo); + self::assertEquals('foo', $foo[0]->getName()); $bar = $repo->findPackages('bar'); - $this->assertCount(2, $bar); - $this->assertEquals('bar', $bar[0]->getName()); + self::assertCount(2, $bar); + self::assertEquals('bar', $bar[0]->getName()); } public function testAutomaticallyAddAliasedPackageButNotRemove(): void @@ -77,13 +77,13 @@ class ArrayRepositoryTest extends TestCase $repo->addPackage($alias); - $this->assertCount(2, $repo); - $this->assertTrue($repo->hasPackage(self::getPackage('foo', '1'))); - $this->assertTrue($repo->hasPackage(self::getPackage('foo', '2'))); + self::assertCount(2, $repo); + self::assertTrue($repo->hasPackage(self::getPackage('foo', '1'))); + self::assertTrue($repo->hasPackage(self::getPackage('foo', '2'))); $repo->removePackage($alias); - $this->assertCount(1, $repo); + self::assertCount(1, $repo); } public function testSearch(): void @@ -93,17 +93,17 @@ class ArrayRepositoryTest extends TestCase $repo->addPackage(self::getPackage('foo', '1')); $repo->addPackage(self::getPackage('bar', '1')); - $this->assertSame( + self::assertSame( [['name' => 'foo', 'description' => null]], $repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT) ); - $this->assertSame( + self::assertSame( [['name' => 'bar', 'description' => null]], $repo->search('bar') ); - $this->assertEmpty( + self::assertEmpty( $repo->search('foobar') ); } @@ -119,14 +119,14 @@ class ArrayRepositoryTest extends TestCase $package->setType('composer-plugin'); $repo->addPackage($package); - $this->assertSame( + self::assertSame( [['name' => 'foo', 'description' => null]], $repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library') ); - $this->assertEmpty($repo->search('bar', RepositoryInterface::SEARCH_FULLTEXT, 'package')); + self::assertEmpty($repo->search('bar', RepositoryInterface::SEARCH_FULLTEXT, 'package')); - $this->assertSame( + self::assertSame( [['name' => 'foobar', 'description' => null]], $repo->search('foo', 0, 'composer-plugin') ); @@ -143,7 +143,7 @@ class ArrayRepositoryTest extends TestCase $package2->setAbandoned('bar'); $repo->addPackage($package2); - $this->assertSame( + self::assertSame( [ ['name' => 'foo1', 'description' => null, 'abandoned' => true], ['name' => 'foo2', 'description' => null, 'abandoned' => 'bar'], diff --git a/tests/Composer/Test/Repository/ArtifactRepositoryTest.php b/tests/Composer/Test/Repository/ArtifactRepositoryTest.php index 52b2b568c..1db3263a1 100644 --- a/tests/Composer/Test/Repository/ArtifactRepositoryTest.php +++ b/tests/Composer/Test/Repository/ArtifactRepositoryTest.php @@ -51,14 +51,14 @@ class ArtifactRepositoryTest extends TestCase sort($expectedPackages); sort($foundPackages); - $this->assertSame($expectedPackages, $foundPackages); + self::assertSame($expectedPackages, $foundPackages); $tarPackage = array_filter($repo->getPackages(), static function (BasePackage $package): bool { return $package->getPrettyName() === 'test/jsonInRootTarFile'; }); - $this->assertCount(1, $tarPackage); + self::assertCount(1, $tarPackage); $tarPackage = array_pop($tarPackage); - $this->assertSame('tar', $tarPackage->getDistType()); + self::assertSame('tar', $tarPackage->getDistType()); } public function testAbsoluteRepoUrlCreatesAbsoluteUrlPackages(): void @@ -68,7 +68,7 @@ class ArtifactRepositoryTest extends TestCase $repo = new ArtifactRepository($coordinates, new NullIO()); foreach ($repo->getPackages() as $package) { - $this->assertSame(strpos($package->getDistUrl(), strtr($absolutePath, '\\', '/')), 0); + self::assertSame(strpos($package->getDistUrl(), strtr($absolutePath, '\\', '/')), 0); } } @@ -79,7 +79,7 @@ class ArtifactRepositoryTest extends TestCase $repo = new ArtifactRepository($coordinates, new NullIO()); foreach ($repo->getPackages() as $package) { - $this->assertSame(strpos($package->getDistUrl(), $relativePath), 0); + self::assertSame(strpos($package->getDistUrl(), $relativePath), 0); } } } diff --git a/tests/Composer/Test/Repository/ComposerRepositoryTest.php b/tests/Composer/Test/Repository/ComposerRepositoryTest.php index 6eba1081d..5355c07a6 100644 --- a/tests/Composer/Test/Repository/ComposerRepositoryTest.php +++ b/tests/Composer/Test/Repository/ComposerRepositoryTest.php @@ -55,7 +55,7 @@ class ComposerRepositoryTest extends TestCase $packages = $repository->getPackages(); // Final sanity check, ensure the correct number of packages were added. - $this->assertCount(count($expected), $packages); + self::assertCount(count($expected), $packages); foreach ($expected as $index => $pkg) { self::assertSame($pkg['name'].' '.$pkg['version'], $packages[$index]->getName().' '.$packages[$index]->getPrettyVersion()); @@ -165,9 +165,9 @@ class ComposerRepositoryTest extends TestCase $reflMethod->setAccessible(true); $packages = $reflMethod->invoke($repo, 'a'); - $this->assertCount(5, $packages); - $this->assertEquals(['1', '1-alias', '2', '2-alias', '3'], array_keys($packages)); - $this->assertSame($packages['2'], $packages['2-alias']->getAliasOf()); + self::assertCount(5, $packages); + self::assertEquals(['1', '1-alias', '2', '2-alias', '3'], array_keys($packages)); + self::assertSame($packages['2'], $packages['2-alias']->getAliasOf()); } public function testSearchWithType(): void @@ -202,12 +202,12 @@ class ComposerRepositoryTest extends TestCase $config->merge(['config' => ['cache-read-only' => true]]); $repository = new ComposerRepository($repoConfig, new NullIO, $config, $httpDownloader, $eventDispatcher); - $this->assertSame( + self::assertSame( [['name' => 'foo', 'description' => null]], $repository->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'composer-plugin') ); - $this->assertEmpty( + self::assertEmpty( $repository->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library') ); } @@ -234,7 +234,7 @@ class ComposerRepositoryTest extends TestCase $config->merge(['config' => ['cache-read-only' => true]]); $repository = new ComposerRepository($repoConfig, new NullIO, $config, $httpDownloader, $eventDispatcher); - $this->assertEmpty( + self::assertEmpty( $repository->search('foo bar', RepositoryInterface::SEARCH_FULLTEXT) ); } @@ -277,7 +277,7 @@ class ComposerRepositoryTest extends TestCase $config->merge(['config' => ['cache-read-only' => true]]); $repository = new ComposerRepository($repoConfig, new NullIO, $config, $httpDownloader, $eventDispatcher); - $this->assertSame( + self::assertSame( [ ['name' => 'foo1', 'description' => null, 'abandoned' => true], ['name' => 'foo2', 'description' => null, 'abandoned' => 'bar'], @@ -312,7 +312,7 @@ class ComposerRepositoryTest extends TestCase $property->setAccessible(true); $property->setValue($repository, $repositoryUrl); - $this->assertSame($expected, $method->invoke($repository, $url)); + self::assertSame($expected, $method->invoke($repository, $url)); } public static function provideCanonicalizeUrlTestCases(): array @@ -379,7 +379,7 @@ class ComposerRepositoryTest extends TestCase $httpDownloader ); - $this->assertEquals(['foo/bar'], $repository->getPackageNames()); + self::assertEquals(['foo/bar'], $repository->getPackageNames()); } public function testGetSecurityAdvisoriesAssertRepositoryHttpOptionsAreUsed(): void @@ -425,7 +425,7 @@ class ComposerRepositoryTest extends TestCase $httpDownloader ); - $this->assertSame([ + self::assertSame([ 'namesFound' => [], 'advisories' => [], ], $repository->getSecurityAdvisories(['foo/bar' => new Constraint('=', '1.0.0.0')])); diff --git a/tests/Composer/Test/Repository/CompositeRepositoryTest.php b/tests/Composer/Test/Repository/CompositeRepositoryTest.php index 098396c9b..ea2e7ffda 100644 --- a/tests/Composer/Test/Repository/CompositeRepositoryTest.php +++ b/tests/Composer/Test/Repository/CompositeRepositoryTest.php @@ -28,11 +28,11 @@ class CompositeRepositoryTest extends TestCase $repo = new CompositeRepository([$arrayRepoOne, $arrayRepoTwo]); - $this->assertTrue($repo->hasPackage(self::getPackage('foo', '1')), "Should have package 'foo/1'"); - $this->assertTrue($repo->hasPackage(self::getPackage('bar', '1')), "Should have package 'bar/1'"); + self::assertTrue($repo->hasPackage(self::getPackage('foo', '1')), "Should have package 'foo/1'"); + self::assertTrue($repo->hasPackage(self::getPackage('bar', '1')), "Should have package 'bar/1'"); - $this->assertFalse($repo->hasPackage(self::getPackage('foo', '2')), "Should not have package 'foo/2'"); - $this->assertFalse($repo->hasPackage(self::getPackage('bar', '2')), "Should not have package 'bar/2'"); + self::assertFalse($repo->hasPackage(self::getPackage('foo', '2')), "Should not have package 'foo/2'"); + self::assertFalse($repo->hasPackage(self::getPackage('bar', '2')), "Should not have package 'bar/2'"); } public function testFindPackage(): void @@ -45,11 +45,11 @@ class CompositeRepositoryTest extends TestCase $repo = new CompositeRepository([$arrayRepoOne, $arrayRepoTwo]); - $this->assertEquals('foo', $repo->findPackage('foo', '1')->getName(), "Should find package 'foo/1' and get name of 'foo'"); - $this->assertEquals('1', $repo->findPackage('foo', '1')->getPrettyVersion(), "Should find package 'foo/1' and get pretty version of '1'"); - $this->assertEquals('bar', $repo->findPackage('bar', '1')->getName(), "Should find package 'bar/1' and get name of 'bar'"); - $this->assertEquals('1', $repo->findPackage('bar', '1')->getPrettyVersion(), "Should find package 'bar/1' and get pretty version of '1'"); - $this->assertNull($repo->findPackage('foo', '2'), "Should not find package 'foo/2'"); + self::assertEquals('foo', $repo->findPackage('foo', '1')->getName(), "Should find package 'foo/1' and get name of 'foo'"); + self::assertEquals('1', $repo->findPackage('foo', '1')->getPrettyVersion(), "Should find package 'foo/1' and get pretty version of '1'"); + self::assertEquals('bar', $repo->findPackage('bar', '1')->getName(), "Should find package 'bar/1' and get name of 'bar'"); + self::assertEquals('1', $repo->findPackage('bar', '1')->getPrettyVersion(), "Should find package 'bar/1' and get pretty version of '1'"); + self::assertNull($repo->findPackage('foo', '2'), "Should not find package 'foo/2'"); } public function testFindPackages(): void @@ -67,16 +67,16 @@ class CompositeRepositoryTest extends TestCase $repo = new CompositeRepository([$arrayRepoOne, $arrayRepoTwo]); $bats = $repo->findPackages('bat'); - $this->assertCount(1, $bats, "Should find one instance of 'bats' (defined in just one repository)"); - $this->assertEquals('bat', $bats[0]->getName(), "Should find packages named 'bat'"); + self::assertCount(1, $bats, "Should find one instance of 'bats' (defined in just one repository)"); + self::assertEquals('bat', $bats[0]->getName(), "Should find packages named 'bat'"); $bars = $repo->findPackages('bar'); - $this->assertCount(2, $bars, "Should find two instances of 'bar' (both defined in the same repository)"); - $this->assertEquals('bar', $bars[0]->getName(), "Should find packages named 'bar'"); + self::assertCount(2, $bars, "Should find two instances of 'bar' (both defined in the same repository)"); + self::assertEquals('bar', $bars[0]->getName(), "Should find packages named 'bar'"); $foos = $repo->findPackages('foo'); - $this->assertCount(3, $foos, "Should find three instances of 'foo' (two defined in one repository, the third in the other)"); - $this->assertEquals('foo', $foos[0]->getName(), "Should find packages named 'foo'"); + self::assertCount(3, $foos, "Should find three instances of 'foo' (two defined in one repository, the third in the other)"); + self::assertEquals('foo', $foos[0]->getName(), "Should find packages named 'foo'"); } public function testGetPackages(): void @@ -90,11 +90,11 @@ class CompositeRepositoryTest extends TestCase $repo = new CompositeRepository([$arrayRepoOne, $arrayRepoTwo]); $packages = $repo->getPackages(); - $this->assertCount(2, $packages, "Should get two packages"); - $this->assertEquals("foo", $packages[0]->getName(), "First package should have name of 'foo'"); - $this->assertEquals("1", $packages[0]->getPrettyVersion(), "First package should have pretty version of '1'"); - $this->assertEquals("bar", $packages[1]->getName(), "Second package should have name of 'bar'"); - $this->assertEquals("1", $packages[1]->getPrettyVersion(), "Second package should have pretty version of '1'"); + self::assertCount(2, $packages, "Should get two packages"); + self::assertEquals("foo", $packages[0]->getName(), "First package should have name of 'foo'"); + self::assertEquals("1", $packages[0]->getPrettyVersion(), "First package should have pretty version of '1'"); + self::assertEquals("bar", $packages[1]->getName(), "Second package should have name of 'bar'"); + self::assertEquals("1", $packages[1]->getPrettyVersion(), "Second package should have pretty version of '1'"); } public function testAddRepository(): void @@ -108,9 +108,9 @@ class CompositeRepositoryTest extends TestCase $arrayRepoTwo->addPackage(self::getPackage('bar', '3')); $repo = new CompositeRepository([$arrayRepoOne]); - $this->assertCount(1, $repo, "Composite repository should have just one package before addRepository() is called"); + self::assertCount(1, $repo, "Composite repository should have just one package before addRepository() is called"); $repo->addRepository($arrayRepoTwo); - $this->assertCount(4, $repo, "Composite repository should have four packages after addRepository() is called"); + self::assertCount(4, $repo, "Composite repository should have four packages after addRepository() is called"); } public function testCount(): void @@ -123,7 +123,7 @@ class CompositeRepositoryTest extends TestCase $repo = new CompositeRepository([$arrayRepoOne, $arrayRepoTwo]); - $this->assertCount(2, $repo, "Should return '2' for count(\$repo)"); + self::assertCount(2, $repo, "Should return '2' for count(\$repo)"); } /** @@ -134,7 +134,7 @@ class CompositeRepositoryTest extends TestCase public function testNoRepositories(string $method, array $args): void { $repo = new CompositeRepository([]); - $this->assertEquals([], call_user_func_array([$repo, $method], $args)); + self::assertEquals([], call_user_func_array([$repo, $method], $args)); } public static function provideMethodCalls(): array diff --git a/tests/Composer/Test/Repository/FilesystemRepositoryTest.php b/tests/Composer/Test/Repository/FilesystemRepositoryTest.php index e932ef4a8..c4f62a655 100644 --- a/tests/Composer/Test/Repository/FilesystemRepositoryTest.php +++ b/tests/Composer/Test/Repository/FilesystemRepositoryTest.php @@ -39,10 +39,10 @@ class FilesystemRepositoryTest extends TestCase $packages = $repository->getPackages(); - $this->assertCount(1, $packages); - $this->assertSame('package1', $packages[0]->getName()); - $this->assertSame('1.0.0.0-beta', $packages[0]->getVersion()); - $this->assertSame('vendor', $packages[0]->getType()); + self::assertCount(1, $packages); + self::assertSame('package1', $packages[0]->getName()); + self::assertSame('1.0.0.0-beta', $packages[0]->getVersion()); + self::assertSame('vendor', $packages[0]->getType()); } public function testCorruptedRepositoryFile(): void @@ -75,7 +75,7 @@ class FilesystemRepositoryTest extends TestCase ->method('exists') ->will($this->returnValue(false)); - $this->assertEquals([], $repository->getPackages()); + self::assertEquals([], $repository->getPackages()); } public function testRepositoryWrite(): void @@ -195,7 +195,7 @@ class FilesystemRepositoryTest extends TestCase })); $repository->write(true, $im); - $this->assertSame(file_get_contents(__DIR__.'/Fixtures/installed.php'), file_get_contents($dir.'/installed.php')); + self::assertSame(file_get_contents(__DIR__.'/Fixtures/installed.php'), file_get_contents($dir.'/installed.php')); } public function testSafelyLoadInstalledVersions(): void diff --git a/tests/Composer/Test/Repository/FilterRepositoryTest.php b/tests/Composer/Test/Repository/FilterRepositoryTest.php index 726cc549c..8698f97f8 100644 --- a/tests/Composer/Test/Repository/FilterRepositoryTest.php +++ b/tests/Composer/Test/Repository/FilterRepositoryTest.php @@ -45,7 +45,7 @@ class FilterRepositoryTest extends TestCase $repo = new FilterRepository($this->arrayRepo, $config); $packages = $repo->getPackages(); - $this->assertSame($expected, array_map(static function ($p): string { + self::assertSame($expected, array_map(static function ($p): string { return $p->getName(); }, $packages)); } @@ -87,15 +87,15 @@ class FilterRepositoryTest extends TestCase { $repo = new FilterRepository($this->arrayRepo, []); $result = $repo->loadPackages(['foo/aaa' => new MatchAllConstraint], BasePackage::$stabilities, []); - $this->assertCount(1, $result['packages']); - $this->assertCount(1, $result['namesFound']); + self::assertCount(1, $result['packages']); + self::assertCount(1, $result['namesFound']); } public function testNonCanonical(): void { $repo = new FilterRepository($this->arrayRepo, ['canonical' => false]); $result = $repo->loadPackages(['foo/aaa' => new MatchAllConstraint], BasePackage::$stabilities, []); - $this->assertCount(1, $result['packages']); - $this->assertCount(0, $result['namesFound']); + self::assertCount(1, $result['packages']); + self::assertCount(0, $result['namesFound']); } } diff --git a/tests/Composer/Test/Repository/InstalledRepositoryTest.php b/tests/Composer/Test/Repository/InstalledRepositoryTest.php index 127c58b8f..47726ecad 100644 --- a/tests/Composer/Test/Repository/InstalledRepositoryTest.php +++ b/tests/Composer/Test/Repository/InstalledRepositoryTest.php @@ -36,9 +36,9 @@ class InstalledRepositoryTest extends TestCase $repo = new InstalledRepository([$arrayRepoOne, $arrayRepoTwo]); - $this->assertEquals([$foo2], $repo->findPackagesWithReplacersAndProviders('foo', '2')); - $this->assertEquals([$bar], $repo->findPackagesWithReplacersAndProviders('bar', '1')); - $this->assertEquals([$foo, $bar2], $repo->findPackagesWithReplacersAndProviders('provided')); + self::assertEquals([$foo2], $repo->findPackagesWithReplacersAndProviders('foo', '2')); + self::assertEquals([$bar], $repo->findPackagesWithReplacersAndProviders('bar', '1')); + self::assertEquals([$foo, $bar2], $repo->findPackagesWithReplacersAndProviders('provided')); } public function testAddRepository(): void diff --git a/tests/Composer/Test/Repository/PathRepositoryTest.php b/tests/Composer/Test/Repository/PathRepositoryTest.php index 5edd4c423..f30aee388 100644 --- a/tests/Composer/Test/Repository/PathRepositoryTest.php +++ b/tests/Composer/Test/Repository/PathRepositoryTest.php @@ -36,8 +36,8 @@ class PathRepositoryTest extends TestCase $repository = $this->createPathRepo(['url' => $repositoryUrl]); $repository->getPackages(); - $this->assertSame(1, $repository->count()); - $this->assertTrue($repository->hasPackage(self::getPackage('test/path-versioned', '0.0.2'))); + self::assertSame(1, $repository->count()); + self::assertTrue($repository->hasPackage(self::getPackage('test/path-versioned', '0.0.2'))); } public function testLoadPackageFromFileSystemWithoutVersion(): void @@ -46,13 +46,13 @@ class PathRepositoryTest extends TestCase $repository = $this->createPathRepo(['url' => $repositoryUrl]); $packages = $repository->getPackages(); - $this->assertGreaterThanOrEqual(1, $repository->count()); + self::assertGreaterThanOrEqual(1, $repository->count()); $package = $packages[0]; - $this->assertSame('test/path-unversioned', $package->getName()); + self::assertSame('test/path-unversioned', $package->getName()); $packageVersion = $package->getVersion(); - $this->assertNotEmpty($packageVersion); + self::assertNotEmpty($packageVersion); } public function testLoadPackageFromFileSystemWithWildcard(): void @@ -62,7 +62,7 @@ class PathRepositoryTest extends TestCase $packages = $repository->getPackages(); $names = []; - $this->assertGreaterThanOrEqual(2, $repository->count()); + self::assertGreaterThanOrEqual(2, $repository->count()); $package = $packages[0]; $names[] = $package->getName(); @@ -71,7 +71,7 @@ class PathRepositoryTest extends TestCase $names[] = $package->getName(); sort($names); - $this->assertEquals(['test/path-unversioned', 'test/path-versioned'], $names); + self::assertEquals(['test/path-unversioned', 'test/path-versioned'], $names); } public function testLoadPackageWithExplicitVersions(): void @@ -88,7 +88,7 @@ class PathRepositoryTest extends TestCase $versions = []; - $this->assertEquals(2, $repository->count()); + self::assertEquals(2, $repository->count()); $package = $packages[0]; $versions[$package->getName()] = $package->getVersion(); @@ -97,7 +97,7 @@ class PathRepositoryTest extends TestCase $versions[$package->getName()] = $package->getVersion(); ksort($versions); - $this->assertSame(['test/path-unversioned' => '4.3.2.1', 'test/path-versioned' => '3.2.1.0'], $versions); + self::assertSame(['test/path-unversioned' => '4.3.2.1', 'test/path-versioned' => '3.2.1.0'], $versions); } /** @@ -115,14 +115,14 @@ class PathRepositoryTest extends TestCase $repository = $this->createPathRepo(['url' => $relativeUrl]); $packages = $repository->getPackages(); - $this->assertSame(1, $repository->count()); + self::assertSame(1, $repository->count()); $package = $packages[0]; - $this->assertSame('test/path-versioned', $package->getName()); + self::assertSame('test/path-versioned', $package->getName()); // Convert platform specific separators back to generic URL slashes $relativeUrl = str_replace(DIRECTORY_SEPARATOR, '/', $relativeUrl); - $this->assertSame($relativeUrl, $package->getDistUrl()); + self::assertSame($relativeUrl, $package->getDistUrl()); } public function testReferenceNone(): void @@ -134,10 +134,10 @@ class PathRepositoryTest extends TestCase $repository = $this->createPathRepo(['url' => $repositoryUrl, 'options' => $options]); $packages = $repository->getPackages(); - $this->assertGreaterThanOrEqual(2, $repository->count()); + self::assertGreaterThanOrEqual(2, $repository->count()); foreach ($packages as $package) { - $this->assertEquals($package->getDistReference(), null); + self::assertEquals($package->getDistReference(), null); } } @@ -151,10 +151,10 @@ class PathRepositoryTest extends TestCase $repository = $this->createPathRepo(['url' => $repositoryUrl, 'options' => $options]); $packages = $repository->getPackages(); - $this->assertGreaterThanOrEqual(2, $repository->count()); + self::assertGreaterThanOrEqual(2, $repository->count()); foreach ($packages as $package) { - $this->assertEquals( + self::assertEquals( $package->getDistReference(), sha1(file_get_contents($package->getDistUrl() . '/composer.json') . serialize($options)) ); diff --git a/tests/Composer/Test/Repository/PlatformRepositoryTest.php b/tests/Composer/Test/Repository/PlatformRepositoryTest.php index aa7ddb8dd..df52653d3 100644 --- a/tests/Composer/Test/Repository/PlatformRepositoryTest.php +++ b/tests/Composer/Test/Repository/PlatformRepositoryTest.php @@ -1256,8 +1256,8 @@ Linked Version => 1.2.11', } else { self::assertNotNull($package, sprintf('Expected to find package "%s"', $packageName)); self::assertSame($expectedVersion, $package->getPrettyVersion(), sprintf('Expected version %s for %s', $expectedVersion, $packageName)); - $this->assertPackageLinks('replaces', $expectedReplaces, $package, $package->getReplaces()); - $this->assertPackageLinks('provides', $expectedProvides, $package, $package->getProvides()); + self::assertPackageLinks('replaces', $expectedReplaces, $package, $package->getReplaces()); + self::assertPackageLinks('provides', $expectedProvides, $package, $package->getProvides()); } } } diff --git a/tests/Composer/Test/Repository/RepositoryFactoryTest.php b/tests/Composer/Test/Repository/RepositoryFactoryTest.php index 8b0a944c0..b318e030b 100644 --- a/tests/Composer/Test/Repository/RepositoryFactoryTest.php +++ b/tests/Composer/Test/Repository/RepositoryFactoryTest.php @@ -30,7 +30,7 @@ class RepositoryFactoryTest extends TestCase $ref->setAccessible(true); $repositoryClasses = $ref->getValue($manager); - $this->assertEquals([ + self::assertEquals([ 'composer', 'vcs', 'package', @@ -60,7 +60,7 @@ class RepositoryFactoryTest extends TestCase */ public function testGenerateRepositoryName($index, array $config, array $existingRepos, string $expected): void { - $this->assertSame($expected, RepositoryFactory::generateRepositoryName($index, $config, $existingRepos)); + self::assertSame($expected, RepositoryFactory::generateRepositoryName($index, $config, $existingRepos)); } public static function generateRepositoryNameProvider(): array diff --git a/tests/Composer/Test/Repository/RepositoryManagerTest.php b/tests/Composer/Test/Repository/RepositoryManagerTest.php index d1fa09c8b..859826e6a 100644 --- a/tests/Composer/Test/Repository/RepositoryManagerTest.php +++ b/tests/Composer/Test/Repository/RepositoryManagerTest.php @@ -50,21 +50,17 @@ class RepositoryManagerTest extends TestCase $rm->addRepository($repository1); $rm->prependRepository($repository2); - $this->assertEquals([$repository2, $repository1], $rm->getRepositories()); + self::assertEquals([$repository2, $repository1], $rm->getRepositories()); } /** * @dataProvider provideRepoCreationTestCases * + * @doesNotPerformAssertions * @param array $options - * @param class-string<\Throwable>|null $exception */ - public function testRepoCreation(string $type, array $options, ?string $exception = null): void + public function testRepoCreation(string $type, array $options): void { - if ($exception !== null) { - self::expectException($exception); - } - $rm = new RepositoryManager( $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $config = new Config, @@ -86,7 +82,7 @@ class RepositoryManagerTest extends TestCase $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository'); $rm->createRepository('composer', ['url' => 'http://example.org']); - $this->assertInstanceOf('Composer\Repository\RepositoryInterface', $rm->createRepository($type, $options)); + $rm->createRepository($type, $options); } public static function provideRepoCreationTestCases(): array @@ -97,9 +93,7 @@ class RepositoryManagerTest extends TestCase ['git', ['url' => 'http://github.com/foo/bar']], ['git', ['url' => 'git@example.org:foo/bar.git']], ['svn', ['url' => 'svn://example.org/foo/bar']], - ['pear', ['url' => 'http://pear.example.org/foo'], 'InvalidArgumentException'], ['package', ['package' => []]], - ['invalid', [], 'InvalidArgumentException'], ]; if (class_exists('ZipArchive')) { @@ -109,6 +103,36 @@ class RepositoryManagerTest extends TestCase return $cases; } + /** + * @dataProvider provideInvalidRepoCreationTestCases + * + * @param array $options + */ + public function testInvalidRepoCreationThrows(string $type, array $options): void + { + self::expectException('InvalidArgumentException'); + + $rm = new RepositoryManager( + $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), + $config = new Config, + $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock(), + $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock() + ); + + $tmpdir = $this->tmpdir; + $config->merge(['config' => ['cache-repo-dir' => $tmpdir]]); + + $rm->createRepository($type, $options); + } + + public static function provideInvalidRepoCreationTestCases(): array + { + return [ + ['pear', ['url' => 'http://pear.example.org/foo']], + ['invalid', []], + ]; + } + public function testFilterRepoWrapping(): void { $rm = new RepositoryManager( @@ -122,7 +146,7 @@ class RepositoryManagerTest extends TestCase /** @var \Composer\Repository\FilterRepository $repo */ $repo = $rm->createRepository('path', ['type' => 'path', 'url' => __DIR__, 'only' => ['foo/bar']]); - $this->assertInstanceOf('Composer\Repository\FilterRepository', $repo); - $this->assertInstanceOf('Composer\Repository\PathRepository', $repo->getRepository()); + self::assertInstanceOf('Composer\Repository\FilterRepository', $repo); + self::assertInstanceOf('Composer\Repository\PathRepository', $repo->getRepository()); } } diff --git a/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php b/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php index 06ec3d177..854c55e33 100644 --- a/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php @@ -62,6 +62,6 @@ class FossilDriverTest extends TestCase { $config = new Config(); $result = FossilDriver::supports($this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $config, $url); - $this->assertEquals($assertion, $result); + self::assertEquals($assertion, $result); } } diff --git a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php index 5050b0fb4..d1fa2bb23 100644 --- a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php @@ -111,12 +111,12 @@ class GitBitbucketDriverTest extends TestCase ['url' => $urls[4], 'body' => '{"date": "2016-05-17T13:19:52+00:00"}'], ], true); - $this->assertEquals( + self::assertEquals( 'main', $driver->getRootIdentifier() ); - $this->assertEquals( + self::assertEquals( [ '1.0.1' => '9b78a3932143497c519e49b8241083838c8ff8a1', '1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb', @@ -124,14 +124,14 @@ class GitBitbucketDriverTest extends TestCase $driver->getTags() ); - $this->assertEquals( + self::assertEquals( [ 'main' => '937992d19d72b5116c3e8c4a04f960e5fa270b22', ], $driver->getBranches() ); - $this->assertEquals( + self::assertEquals( [ 'name' => 'user/repo', 'description' => 'test repo', @@ -167,9 +167,9 @@ class GitBitbucketDriverTest extends TestCase { $url = 'https://bitbucket.org/user/repo.git'; - $this->assertEquals($url, $driver->getUrl()); + self::assertEquals($url, $driver->getUrl()); - $this->assertEquals( + self::assertEquals( [ 'type' => 'zip', 'url' => 'https://bitbucket.org/user/repo/get/reference.zip', @@ -179,7 +179,7 @@ class GitBitbucketDriverTest extends TestCase $driver->getDist('reference') ); - $this->assertEquals( + self::assertEquals( ['type' => 'git', 'url' => $url, 'reference' => 'reference'], $driver->getSource('reference') ); @@ -217,22 +217,22 @@ class GitBitbucketDriverTest extends TestCase $driver->getRootIdentifier(); $data = $driver->getComposerInformation('main'); - $this->assertIsArray($data); - $this->assertSame('https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=main', $data['support']['source']); + self::assertIsArray($data); + self::assertSame('https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=main', $data['support']['source']); } public function testSupports(): void { - $this->assertTrue( + self::assertTrue( GitBitbucketDriver::supports($this->io, $this->config, 'https://bitbucket.org/user/repo.git') ); // should not be changed, see https://github.com/composer/composer/issues/9400 - $this->assertFalse( + self::assertFalse( GitBitbucketDriver::supports($this->io, $this->config, 'git@bitbucket.org:user/repo.git') ); - $this->assertFalse( + self::assertFalse( GitBitbucketDriver::supports($this->io, $this->config, 'https://github.com/user/repo.git') ); } diff --git a/tests/Composer/Test/Repository/Vcs/GitDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitDriverTest.php index b54e29ad1..daa8b1aea 100644 --- a/tests/Composer/Test/Repository/Vcs/GitDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitDriverTest.php @@ -76,7 +76,7 @@ GIT; 'stdout' => $stdout, ]], true); - $this->assertSame('main', $driver->getRootIdentifier()); + self::assertSame('main', $driver->getRootIdentifier()); } public function testGetRootIdentifierFromRemote(): void @@ -109,7 +109,7 @@ GIT; 'stdout' => $stdout, ]]); - $this->assertSame('main', $driver->getRootIdentifier()); + self::assertSame('main', $driver->getRootIdentifier()); } public function testGetRootIdentifierFromLocalWithNetworkDisabled(): void @@ -134,7 +134,7 @@ GIT; 'stdout' => $stdout, ]]); - $this->assertSame('main', $driver->getRootIdentifier()); + self::assertSame('main', $driver->getRootIdentifier()); } public function testGetBranchesFilterInvalidBranchNames(): void @@ -160,7 +160,7 @@ GIT; ]]); $branches = $driver->getBranches(); - $this->assertSame([ + self::assertSame([ 'main' => '089681446ba44d6d9004350192486f2ceb4eaa06', '2.2' => '12681446ba44d6d9004350192486f2ceb4eaa06', ], $branches); @@ -174,7 +174,7 @@ GIT; $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $driver = new GitDriver(['url' => 'https://example.org/acme.git'], $io, $this->config, $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock(), $process); - $this->assertNull($driver->getFileContent('file.txt', 'h')); + self::assertNull($driver->getFileContent('file.txt', 'h')); $driver->getFileContent('file.txt', '-h'); } diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index aa454e894..f7e62ca64 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -91,18 +91,18 @@ class GitHubDriverTest extends TestCase $gitHubDriver->initialize(); $this->setAttribute($gitHubDriver, 'tags', [$identifier => $sha]); - $this->assertEquals('test_master', $gitHubDriver->getRootIdentifier()); + self::assertEquals('test_master', $gitHubDriver->getRootIdentifier()); $dist = $gitHubDriver->getDist($sha); self::assertIsArray($dist); - $this->assertEquals('zip', $dist['type']); - $this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']); - $this->assertEquals('SOMESHA', $dist['reference']); + self::assertEquals('zip', $dist['type']); + self::assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']); + self::assertEquals('SOMESHA', $dist['reference']); $source = $gitHubDriver->getSource($sha); - $this->assertEquals('git', $source['type']); - $this->assertEquals($repoSshUrl, $source['url']); - $this->assertEquals('SOMESHA', $source['reference']); + self::assertEquals('git', $source['type']); + self::assertEquals($repoSshUrl, $source['url']); + self::assertEquals('SOMESHA', $source['reference']); } public function testPublicRepository(): void @@ -134,18 +134,18 @@ class GitHubDriverTest extends TestCase $gitHubDriver->initialize(); $this->setAttribute($gitHubDriver, 'tags', [$identifier => $sha]); - $this->assertEquals('test_master', $gitHubDriver->getRootIdentifier()); + self::assertEquals('test_master', $gitHubDriver->getRootIdentifier()); $dist = $gitHubDriver->getDist($sha); self::assertIsArray($dist); - $this->assertEquals('zip', $dist['type']); - $this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']); - $this->assertEquals($sha, $dist['reference']); + self::assertEquals('zip', $dist['type']); + self::assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']); + self::assertEquals($sha, $dist['reference']); $source = $gitHubDriver->getSource($sha); - $this->assertEquals('git', $source['type']); - $this->assertEquals($repoUrl, $source['url']); - $this->assertEquals($sha, $source['reference']); + self::assertEquals('git', $source['type']); + self::assertEquals($repoUrl, $source['url']); + self::assertEquals($sha, $source['reference']); } public function testPublicRepository2(): void @@ -180,23 +180,23 @@ class GitHubDriverTest extends TestCase $gitHubDriver->initialize(); $this->setAttribute($gitHubDriver, 'tags', [$identifier => $sha]); - $this->assertEquals('test_master', $gitHubDriver->getRootIdentifier()); + self::assertEquals('test_master', $gitHubDriver->getRootIdentifier()); $dist = $gitHubDriver->getDist($sha); self::assertIsArray($dist); - $this->assertEquals('zip', $dist['type']); - $this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']); - $this->assertEquals($sha, $dist['reference']); + self::assertEquals('zip', $dist['type']); + self::assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']); + self::assertEquals($sha, $dist['reference']); $source = $gitHubDriver->getSource($sha); - $this->assertEquals('git', $source['type']); - $this->assertEquals($repoUrl, $source['url']); - $this->assertEquals($sha, $source['reference']); + self::assertEquals('git', $source['type']); + self::assertEquals($repoUrl, $source['url']); + self::assertEquals($sha, $source['reference']); $data = $gitHubDriver->getComposerInformation($identifier); - $this->assertIsArray($data); - $this->assertArrayNotHasKey('abandoned', $data); + self::assertIsArray($data); + self::assertArrayNotHasKey('abandoned', $data); } public function testInvalidSupportData(): void @@ -233,8 +233,8 @@ class GitHubDriverTest extends TestCase $data = $gitHubDriver->getComposerInformation($identifier); - $this->assertIsArray($data); - $this->assertSame('https://github.com/composer/packagist/tree/feature/3.2-foo', $data['support']['source']); + self::assertIsArray($data); + self::assertSame('https://github.com/composer/packagist/tree/feature/3.2-foo', $data['support']['source']); } public function testPublicRepositoryArchived(): void @@ -271,8 +271,8 @@ class GitHubDriverTest extends TestCase $data = $gitHubDriver->getComposerInformation($sha); - $this->assertIsArray($data); - $this->assertTrue($data['abandoned']); + self::assertIsArray($data); + self::assertTrue($data['abandoned']); } public function testPrivateRepositoryNoInteraction(): void @@ -326,23 +326,23 @@ class GitHubDriverTest extends TestCase $gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config, $httpDownloader, $process); $gitHubDriver->initialize(); - $this->assertEquals('test_master', $gitHubDriver->getRootIdentifier()); + self::assertEquals('test_master', $gitHubDriver->getRootIdentifier()); $dist = $gitHubDriver->getDist($sha); self::assertIsArray($dist); - $this->assertEquals('zip', $dist['type']); - $this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']); - $this->assertEquals($sha, $dist['reference']); + self::assertEquals('zip', $dist['type']); + self::assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']); + self::assertEquals($sha, $dist['reference']); $source = $gitHubDriver->getSource($identifier); - $this->assertEquals('git', $source['type']); - $this->assertEquals($repoSshUrl, $source['url']); - $this->assertEquals($identifier, $source['reference']); + self::assertEquals('git', $source['type']); + self::assertEquals($repoSshUrl, $source['url']); + self::assertEquals($identifier, $source['reference']); $source = $gitHubDriver->getSource($sha); - $this->assertEquals('git', $source['type']); - $this->assertEquals($repoSshUrl, $source['url']); - $this->assertEquals($sha, $source['reference']); + self::assertEquals('git', $source['type']); + self::assertEquals($repoSshUrl, $source['url']); + self::assertEquals($sha, $source['reference']); } /** @@ -384,7 +384,7 @@ class GitHubDriverTest extends TestCase { $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); - $this->assertSame($expected, GitHubDriver::supports($io, $this->config, $repoUrl)); + self::assertSame($expected, GitHubDriver::supports($io, $this->config, $repoUrl)); } /** @@ -426,7 +426,7 @@ class GitHubDriverTest extends TestCase $gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config, $httpDownloader, $this->getProcessExecutorMock()); $gitHubDriver->initialize(); - $this->assertSame('', $gitHubDriver->getFileContent('composer.json', 'main')); + self::assertSame('', $gitHubDriver->getFileContent('composer.json', 'main')); } /** diff --git a/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php index 9d163f567..acc1df9e3 100644 --- a/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php @@ -118,10 +118,10 @@ JSON; $driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); - $this->assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab'); - $this->assertEquals('git@gitlab.com:mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default'); - $this->assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl()); + self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); + self::assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab'); + self::assertEquals('git@gitlab.com:mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default'); + self::assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl()); return $driver; } @@ -158,10 +158,10 @@ JSON; $driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); - $this->assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab'); - $this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default'); - $this->assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl()); + self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); + self::assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab'); + self::assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default'); + self::assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl()); return $driver; } @@ -197,10 +197,10 @@ JSON; $driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); - $this->assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab'); - $this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default'); - $this->assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl()); + self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); + self::assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab'); + self::assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default'); + self::assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl()); return $driver; } @@ -238,10 +238,10 @@ JSON; $driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); - $this->assertEquals('1.0.x', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab'); - $this->assertEquals($url.'.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default'); - $this->assertEquals($url, $driver->getUrl()); + self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); + self::assertEquals('1.0.x', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab'); + self::assertEquals($url.'.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default'); + self::assertEquals($url, $driver->getUrl()); } public function testInvalidSupportData(): void @@ -256,8 +256,8 @@ JSON; $data = $driver->getComposerInformation('main'); - $this->assertIsArray($data); - $this->assertSame('https://gitlab.com/mygroup/myproject/-/tree/main', $data['support']['source']); + self::assertIsArray($data); + self::assertSame('https://gitlab.com/mygroup/myproject/-/tree/main', $data['support']['source']); } public function testGetDist(): void @@ -272,7 +272,7 @@ JSON; 'shasum' => '', ]; - $this->assertEquals($expected, $driver->getDist($reference)); + self::assertEquals($expected, $driver->getDist($reference)); } public function testGetSource(): void @@ -286,7 +286,7 @@ JSON; 'reference' => $reference, ]; - $this->assertEquals($expected, $driver->getSource($reference)); + self::assertEquals($expected, $driver->getSource($reference)); } public function testGetSource_GivenPublicProject(): void @@ -300,7 +300,7 @@ JSON; 'reference' => $reference, ]; - $this->assertEquals($expected, $driver->getSource($reference)); + self::assertEquals($expected, $driver->getSource($reference)); } public function testGetTags(): void @@ -340,8 +340,8 @@ JSON; 'v2.0.0' => '8e8f60b3ec86d63733db3bd6371117a758027ec6', ]; - $this->assertEquals($expected, $driver->getTags()); - $this->assertEquals($expected, $driver->getTags(), 'Tags are cached'); + self::assertEquals($expected, $driver->getTags()); + self::assertEquals($expected, $driver->getTags(), 'Tags are cached'); } public function testGetPaginatedRefs(): void @@ -402,8 +402,8 @@ JSON; 'stagingdupe' => '502cffe49f136443f2059803f2e7192d1ac066cd', ]; - $this->assertEquals($expected, $driver->getBranches()); - $this->assertEquals($expected, $driver->getBranches(), 'Branches are cached'); + self::assertEquals($expected, $driver->getBranches()); + self::assertEquals($expected, $driver->getBranches(), 'Branches are cached'); } public function testGetBranches(): void @@ -444,8 +444,8 @@ JSON; 'staging' => '502cffe49f136443f2059803f2e7192d1ac066cd', ]; - $this->assertEquals($expected, $driver->getBranches()); - $this->assertEquals($expected, $driver->getBranches(), 'Branches are cached'); + self::assertEquals($expected, $driver->getBranches()); + self::assertEquals($expected, $driver->getBranches(), 'Branches are cached'); } /** @@ -454,7 +454,7 @@ JSON; */ public function testSupports(string $url, bool $expected): void { - $this->assertSame($expected, GitLabDriver::supports($this->io, $this->config, $url)); + self::assertSame($expected, GitLabDriver::supports($this->io, $this->config, $url)); } public static function dataForTestSupports(): array @@ -510,7 +510,7 @@ JSON; $driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); + self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); } public function testGitlabSubGroup(): void @@ -542,7 +542,7 @@ JSON; $driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); + self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); } public function testGitlabSubDirectorySubGroup(): void @@ -574,7 +574,7 @@ JSON; $driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); + self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); } public function testForwardsOptions(): void @@ -645,7 +645,7 @@ JSON; $config->merge(['config' => ['gitlab-protocol' => 'http']]); $driver = new GitLabDriver(['url' => $url], $this->io, $config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'Repository URL matches config request for http not git'); + self::assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'Repository URL matches config request for http not git'); } /** diff --git a/tests/Composer/Test/Repository/Vcs/HgDriverTest.php b/tests/Composer/Test/Repository/Vcs/HgDriverTest.php index f1f047de5..42d9f5b4a 100644 --- a/tests/Composer/Test/Repository/Vcs/HgDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/HgDriverTest.php @@ -50,7 +50,7 @@ class HgDriverTest extends TestCase */ public function testSupports(string $repositoryUrl): void { - $this->assertTrue( + self::assertTrue( HgDriver::supports($this->io, $this->config, $repositoryUrl) ); } @@ -93,7 +93,7 @@ HG_BOOKMARKS; ]]); $branches = $driver->getBranches(); - $this->assertSame([ + self::assertSame([ 'help' => 'dbf6c8acb641', 'default' => 'dbf6c8acb640', ], $branches); @@ -106,7 +106,7 @@ HG_BOOKMARKS; $process = $this->getProcessExecutorMock(); $driver = new HgDriver(['url' => 'https://example.org/acme.git'], $this->io, $this->config, $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock(), $process); - $this->assertNull($driver->getFileContent('file.txt', 'h')); + self::assertNull($driver->getFileContent('file.txt', 'h')); $driver->getFileContent('file.txt', '-h'); } diff --git a/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php b/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php index b6165ebab..357a544a4 100644 --- a/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php @@ -132,9 +132,9 @@ class PerforceDriverTest extends TestCase { $driver = new PerforceDriver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->process); $driver->initialize(); - $this->assertEquals(self::TEST_URL, $driver->getUrl()); - $this->assertEquals(self::TEST_DEPOT, $driver->getDepot()); - $this->assertEquals(self::TEST_BRANCH, $driver->getBranch()); + self::assertEquals(self::TEST_URL, $driver->getUrl()); + self::assertEquals(self::TEST_DEPOT, $driver->getDepot()); + self::assertEquals(self::TEST_BRANCH, $driver->getBranch()); } public function testInitializeLogsInAndConnectsClient(): void @@ -157,7 +157,7 @@ class PerforceDriverTest extends TestCase $this->perforce->expects($this->any())->method('getComposerInformation')->with($this->equalTo($formatted_depot_path))->will($this->returnValue([])); $this->driver->initialize(); $result = $this->driver->hasComposerFile($identifier); - $this->assertFalse($result); + self::assertFalse($result); } /** @@ -171,7 +171,7 @@ class PerforceDriverTest extends TestCase $this->perforce->expects($this->any())->method('getComposerInformation')->with($this->equalTo($formatted_depot_path))->will($this->returnValue([''])); $this->driver->initialize(); $result = $this->driver->hasComposerFile($identifier); - $this->assertTrue($result); + self::assertTrue($result); } /** @@ -182,7 +182,7 @@ class PerforceDriverTest extends TestCase public function testSupportsReturnsFalseNoDeepCheck(): void { $this->expectOutputString(''); - $this->assertFalse(PerforceDriver::supports($this->io, $this->config, 'existing.url')); + self::assertFalse(PerforceDriver::supports($this->io, $this->config, 'existing.url')); } public function testCleanup(): void diff --git a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php index 3232f2d4e..d8a76f702 100644 --- a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php @@ -101,6 +101,6 @@ class SvnDriverTest extends TestCase { $config = new Config(); $result = SvnDriver::supports($this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $config, $url); - $this->assertEquals($assertion, $result); + self::assertEquals($assertion, $result); } } diff --git a/tests/Composer/Test/Repository/VcsRepositoryTest.php b/tests/Composer/Test/Repository/VcsRepositoryTest.php index dc219371c..692e716b8 100644 --- a/tests/Composer/Test/Repository/VcsRepositoryTest.php +++ b/tests/Composer/Test/Repository/VcsRepositoryTest.php @@ -177,6 +177,6 @@ class VcsRepositoryTest extends TestCase } } - $this->assertEmpty($expected, 'Missing versions: '.implode(', ', array_keys($expected))); + self::assertEmpty($expected, 'Missing versions: '.implode(', ', array_keys($expected))); } } diff --git a/tests/Composer/Test/Script/EventTest.php b/tests/Composer/Test/Script/EventTest.php index 1647f7169..f62b96cb4 100644 --- a/tests/Composer/Test/Script/EventTest.php +++ b/tests/Composer/Test/Script/EventTest.php @@ -28,15 +28,14 @@ class EventTest extends TestCase $scriptEvent = new Event('test', $composer, $io, true); - $this->assertNull( + self::assertNull( $scriptEvent->getOriginatingEvent(), 'originatingEvent is initialized as null' ); $scriptEvent->setOriginatingEvent($originatingEvent); - // @phpstan-ignore staticMethod.dynamicCall - $this->assertSame( + self::assertSame( $originatingEvent, $scriptEvent->getOriginatingEvent(), 'getOriginatingEvent() SHOULD return test event' @@ -55,13 +54,13 @@ class EventTest extends TestCase $scriptEvent = new Event('test', $composer, $io, true); $scriptEvent->setOriginatingEvent($intermediateEvent); - $this->assertNotSame( + self::assertNotSame( $intermediateEvent, $scriptEvent->getOriginatingEvent(), 'getOriginatingEvent() SHOULD NOT return intermediate events' ); - $this->assertSame( + self::assertSame( $originatingEvent, $scriptEvent->getOriginatingEvent(), 'getOriginatingEvent() SHOULD return upper-most event' diff --git a/tests/Composer/Test/Util/AuthHelperTest.php b/tests/Composer/Test/Util/AuthHelperTest.php index ee5802321..0be55944f 100644 --- a/tests/Composer/Test/Util/AuthHelperTest.php +++ b/tests/Composer/Test/Util/AuthHelperTest.php @@ -57,7 +57,7 @@ class AuthHelperTest extends TestCase ->with($origin) ->willReturn(false); - $this->assertSame( + self::assertSame( $headers, $this->authHelper->addAuthenticationHeader($headers, $origin, $url) ); @@ -80,7 +80,7 @@ class AuthHelperTest extends TestCase $expectedHeaders = array_merge($headers, ['Authorization: Bearer ' . $auth['username']]); - $this->assertSame( + self::assertSame( $expectedHeaders, $this->authHelper->addAuthenticationHeader($headers, $origin, $url) ); @@ -107,7 +107,7 @@ class AuthHelperTest extends TestCase $expectedHeaders = array_merge($headers, ['Authorization: token ' . $auth['username']]); - $this->assertSame( + self::assertSame( $expectedHeaders, $this->authHelper->addAuthenticationHeader($headers, $origin, $url) ); @@ -139,7 +139,7 @@ class AuthHelperTest extends TestCase $expectedHeaders = array_merge($headers, ['Authorization: Bearer ' . $auth['username']]); - $this->assertSame( + self::assertSame( $expectedHeaders, $this->authHelper->addAuthenticationHeader($headers, $origin, $url) ); @@ -182,7 +182,7 @@ class AuthHelperTest extends TestCase $expectedHeaders = array_merge($headers, ['PRIVATE-TOKEN: ' . $auth['username']]); - $this->assertSame( + self::assertSame( $expectedHeaders, $this->authHelper->addAuthenticationHeader($headers, $origin, $url) ); @@ -214,7 +214,7 @@ class AuthHelperTest extends TestCase $expectedHeaders = array_merge($headers, ['Authorization: Bearer ' . $auth['password']]); - $this->assertSame( + self::assertSame( $expectedHeaders, $this->authHelper->addAuthenticationHeader($headers, $origin, $url) ); @@ -250,7 +250,7 @@ class AuthHelperTest extends TestCase ->with('gitlab-domains') ->willReturn([]); - $this->assertSame( + self::assertSame( $headers, $this->authHelper->addAuthenticationHeader($headers, $origin, $url) ); @@ -320,7 +320,7 @@ class AuthHelperTest extends TestCase ['Authorization: Basic ' . base64_encode($auth['username'] . ':' . $auth['password'])] ); - $this->assertSame( + self::assertSame( $expectedHeaders, $this->authHelper->addAuthenticationHeader($headers, $origin, $url) ); @@ -331,12 +331,12 @@ class AuthHelperTest extends TestCase */ public function testIsPublicBitBucketDownloadWithBitbucketPublicUrl(string $url): void { - $this->assertTrue($this->authHelper->isPublicBitBucketDownload($url)); + self::assertTrue($this->authHelper->isPublicBitBucketDownload($url)); } public function testIsPublicBitBucketDownloadWithNonBitbucketPublicUrl(): void { - $this->assertFalse( + self::assertFalse( $this->authHelper->isPublicBitBucketDownload( 'https://bitbucket.org/site/oauth2/authorize' ) @@ -592,12 +592,12 @@ class AuthHelperTest extends TestCase $result1 = $this->authHelper->promptAuthIfNeeded('https://bitbucket.org/workspace/repo1/get/hash1.zip', $origin, 401, 'HTTP/2 401 '); $result2 = $this->authHelper->promptAuthIfNeeded('https://bitbucket.org/workspace/repo2/get/hash2.zip', $origin, 401, 'HTTP/2 401 '); - $this->assertSame( + self::assertSame( $expectedResult, $result1 ); - $this->assertSame( + self::assertSame( $expectedResult, $result2 ); diff --git a/tests/Composer/Test/Util/BitbucketTest.php b/tests/Composer/Test/Util/BitbucketTest.php index dfaac651d..8b977e56f 100644 --- a/tests/Composer/Test/Util/BitbucketTest.php +++ b/tests/Composer/Test/Util/BitbucketTest.php @@ -102,7 +102,7 @@ class BitbucketTest extends TestCase $this->setExpectationsForStoringAccessToken(); - $this->assertEquals( + self::assertEquals( $this->token, $this->bitbucket->requestToken($this->origin, $this->consumer_key, $this->consumer_secret) ); @@ -124,7 +124,7 @@ class BitbucketTest extends TestCase ] ); - $this->assertEquals( + self::assertEquals( $this->token, $this->bitbucket->requestToken($this->origin, $this->consumer_key, $this->consumer_secret) ); @@ -178,7 +178,7 @@ class BitbucketTest extends TestCase $this->setExpectationsForStoringAccessToken(); - $this->assertEquals( + self::assertEquals( $this->token, $this->bitbucket->requestToken($this->origin, $this->consumer_key, $this->consumer_secret) ); @@ -222,7 +222,7 @@ class BitbucketTest extends TestCase ->with('bitbucket-oauth') ->willReturn(null); - $this->assertEquals('', $this->bitbucket->requestToken($this->origin, $this->username, $this->password)); + self::assertEquals('', $this->bitbucket->requestToken($this->origin, $this->username, $this->password)); } public function testRequestAccessTokenWithUsernameAndPasswordWithUnauthorizedResponse(): void @@ -252,7 +252,7 @@ class BitbucketTest extends TestCase ) ->willThrowException(new \Composer\Downloader\TransportException('HTTP/1.1 401 UNAUTHORIZED', 401)); - $this->assertEquals('', $this->bitbucket->requestToken($this->origin, $this->username, $this->password)); + self::assertEquals('', $this->bitbucket->requestToken($this->origin, $this->username, $this->password)); } public function testRequestAccessTokenWithUsernameAndPasswordWithNotFoundResponse(): void @@ -315,7 +315,7 @@ class BitbucketTest extends TestCase $this->setExpectationsForStoringAccessToken(true); - $this->assertTrue($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); + self::assertTrue($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); } public function testAuthorizeOAuthInteractivelyWithEmptyUsername(): void @@ -329,7 +329,7 @@ class BitbucketTest extends TestCase ['ask' => 'Consumer Key (hidden): ', 'reply' => ''], ]); - $this->assertFalse($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); + self::assertFalse($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); } public function testAuthorizeOAuthInteractivelyWithEmptyPassword(): void @@ -345,7 +345,7 @@ class BitbucketTest extends TestCase ['ask' => 'Consumer Secret (hidden): ', 'reply' => ''], ]); - $this->assertFalse($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); + self::assertFalse($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); } public function testAuthorizeOAuthInteractivelyWithRequestAccessTokenFailure(): void @@ -378,7 +378,7 @@ class BitbucketTest extends TestCase ) ); - $this->assertFalse($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); + self::assertFalse($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); } private function setExpectationsForStoringAccessToken(bool $removeBasicAuth = false): void @@ -418,7 +418,7 @@ class BitbucketTest extends TestCase public function testGetTokenWithoutAccessToken(): void { - $this->assertSame('', $this->bitbucket->getToken()); + self::assertSame('', $this->bitbucket->getToken()); } /** @@ -426,12 +426,12 @@ class BitbucketTest extends TestCase */ public function testGetTokenWithAccessToken(Bitbucket $bitbucket): void { - $this->assertSame($this->token, $bitbucket->getToken()); + self::assertSame($this->token, $bitbucket->getToken()); } public function testAuthorizeOAuthWithWrongOriginUrl(): void { - $this->assertFalse($this->bitbucket->authorizeOAuth('non-' . $this->origin)); + self::assertFalse($this->bitbucket->authorizeOAuth('non-' . $this->origin)); } public function testAuthorizeOAuthWithoutAvailableGitConfigToken(): void @@ -441,7 +441,7 @@ class BitbucketTest extends TestCase $bitbucket = new Bitbucket($this->io, $this->config, $process, $this->httpDownloader, $this->time); - $this->assertFalse($bitbucket->authorizeOAuth($this->origin)); + self::assertFalse($bitbucket->authorizeOAuth($this->origin)); } public function testAuthorizeOAuthWithAvailableGitConfigToken(): void @@ -450,6 +450,6 @@ class BitbucketTest extends TestCase $bitbucket = new Bitbucket($this->io, $this->config, $process, $this->httpDownloader, $this->time); - $this->assertTrue($bitbucket->authorizeOAuth($this->origin)); + self::assertTrue($bitbucket->authorizeOAuth($this->origin)); } } diff --git a/tests/Composer/Test/Util/ConfigValidatorTest.php b/tests/Composer/Test/Util/ConfigValidatorTest.php index c6d2bbfde..885390efc 100644 --- a/tests/Composer/Test/Util/ConfigValidatorTest.php +++ b/tests/Composer/Test/Util/ConfigValidatorTest.php @@ -29,7 +29,7 @@ class ConfigValidatorTest extends TestCase $configValidator = new ConfigValidator(new NullIO()); [, , $warnings] = $configValidator->validate(__DIR__ . '/Fixtures/composer_commit-ref.json'); - $this->assertContains( + self::assertContains( 'The package "some/package" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.', $warnings ); @@ -40,7 +40,7 @@ class ConfigValidatorTest extends TestCase $configValidator = new ConfigValidator(new NullIO()); [, , $warnings] = $configValidator->validate(__DIR__ . '/Fixtures/composer_scripts-descriptions.json'); - $this->assertContains( + self::assertContains( 'Description for non-existent script "phpcsxxx" found in "scripts-descriptions"', $warnings ); @@ -51,7 +51,7 @@ class ConfigValidatorTest extends TestCase $configValidator = new ConfigValidator(new NullIO()); [, , $warnings] = $configValidator->validate(__DIR__ . '/Fixtures/composer_scripts-aliases.json'); - $this->assertContains( + self::assertContains( 'Aliases for non-existent script "phpcsxxx" found in "scripts-aliases"', $warnings ); @@ -62,15 +62,15 @@ class ConfigValidatorTest extends TestCase $configValidator = new ConfigValidator(new NullIO()); [, , $warnings] = $configValidator->validate(__DIR__ . '/Fixtures/composer_provide-replace-requirements.json'); - $this->assertContains( + self::assertContains( 'The package a/a in require is also listed in provide which satisfies the requirement. Remove it from provide if you wish to install it.', $warnings ); - $this->assertContains( + self::assertContains( 'The package b/b in require is also listed in replace which satisfies the requirement. Remove it from replace if you wish to install it.', $warnings ); - $this->assertContains( + self::assertContains( 'The package c/c in require-dev is also listed in provide which satisfies the requirement. Remove it from provide if you wish to install it.', $warnings ); diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php index 83a28d75b..cfc0bacaa 100644 --- a/tests/Composer/Test/Util/FilesystemTest.php +++ b/tests/Composer/Test/Util/FilesystemTest.php @@ -57,7 +57,7 @@ class FilesystemTest extends TestCase public function testFindShortestPathCode(string $a, string $b, bool $directory, string $expected, bool $static = false): void { $fs = new Filesystem; - $this->assertEquals($expected, $fs->findShortestPathCode($a, $b, $directory, $static)); + self::assertEquals($expected, $fs->findShortestPathCode($a, $b, $directory, $static)); } public static function providePathCouplesAsCode(): array @@ -116,7 +116,7 @@ class FilesystemTest extends TestCase public function testFindShortestPath(string $a, string $b, string $expected, bool $directory = false): void { $fs = new Filesystem; - $this->assertEquals($expected, $fs->findShortestPath($a, $b, $directory)); + self::assertEquals($expected, $fs->findShortestPath($a, $b, $directory)); } public static function providePathCouples(): array @@ -171,8 +171,8 @@ class FilesystemTest extends TestCase file_put_contents($this->workingDir . "/level1/level2/hello.txt", "hello world"); $fs = new Filesystem; - $this->assertTrue($fs->removeDirectoryPhp($this->workingDir)); - $this->assertFileDoesNotExist($this->workingDir . "/level1/level2/hello.txt"); + self::assertTrue($fs->removeDirectoryPhp($this->workingDir)); + self::assertFileDoesNotExist($this->workingDir . "/level1/level2/hello.txt"); } public function testFileSize(): void @@ -180,7 +180,7 @@ class FilesystemTest extends TestCase file_put_contents($this->testFile, 'Hello'); $fs = new Filesystem; - $this->assertGreaterThanOrEqual(5, $fs->size($this->testFile)); + self::assertGreaterThanOrEqual(5, $fs->size($this->testFile)); } public function testDirectorySize(): void @@ -190,7 +190,7 @@ class FilesystemTest extends TestCase file_put_contents($this->workingDir."/file2.txt", 'World'); $fs = new Filesystem; - $this->assertGreaterThanOrEqual(10, $fs->size($this->workingDir)); + self::assertGreaterThanOrEqual(10, $fs->size($this->workingDir)); } /** @@ -199,7 +199,7 @@ class FilesystemTest extends TestCase public function testNormalizePath(string $expected, string $actual): void { $fs = new Filesystem; - $this->assertEquals($expected, $fs->normalizePath($actual)); + self::assertEquals($expected, $fs->normalizePath($actual)); } public static function provideNormalizedPaths(): array @@ -251,8 +251,8 @@ class FilesystemTest extends TestCase $fs = new Filesystem(); $result = $fs->unlink($symlinked); - $this->assertTrue($result); - $this->assertFileDoesNotExist($symlinked); + self::assertTrue($result); + self::assertFileDoesNotExist($symlinked); } /** @@ -283,9 +283,9 @@ class FilesystemTest extends TestCase $fs = new Filesystem(); $result = $fs->removeDirectory($symlinkedTrailingSlash); - $this->assertTrue($result); - $this->assertFileDoesNotExist($symlinkedTrailingSlash); - $this->assertFileDoesNotExist($symlinked); + self::assertTrue($result); + self::assertFileDoesNotExist($symlinkedTrailingSlash); + self::assertFileDoesNotExist($symlinked); } public function testJunctions(): void @@ -295,8 +295,8 @@ class FilesystemTest extends TestCase // Non-Windows systems do not support this and will return false on all tests, and an exception on creation if (!defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->assertFalse($fs->isJunction($this->workingDir)); - $this->assertFalse($fs->removeJunction($this->workingDir)); + self::assertFalse($fs->isJunction($this->workingDir)); + self::assertFalse($fs->removeJunction($this->workingDir)); self::expectException('LogicException'); self::expectExceptionMessage('not available on non-Windows platform'); } @@ -306,16 +306,16 @@ class FilesystemTest extends TestCase // Create and detect junction $fs->junction($target, $junction); - $this->assertTrue($fs->isJunction($junction), $junction . ': is a junction'); - $this->assertFalse($fs->isJunction($target), $target . ': is not a junction'); - $this->assertTrue($fs->isJunction($target . '/../../junction'), $target . '/../../junction: is a junction'); - $this->assertFalse($fs->isJunction($junction . '/../real'), $junction . '/../real: is not a junction'); - $this->assertTrue($fs->isJunction($junction . '/../junction'), $junction . '/../junction: is a junction'); + self::assertTrue($fs->isJunction($junction), $junction . ': is a junction'); + self::assertFalse($fs->isJunction($target), $target . ': is not a junction'); + self::assertTrue($fs->isJunction($target . '/../../junction'), $target . '/../../junction: is a junction'); + self::assertFalse($fs->isJunction($junction . '/../real'), $junction . '/../real: is not a junction'); + self::assertTrue($fs->isJunction($junction . '/../junction'), $junction . '/../junction: is a junction'); // Remove junction - $this->assertDirectoryExists($junction, $junction . ' is a directory'); - $this->assertTrue($fs->removeJunction($junction), $junction . ' has been removed'); - $this->assertDirectoryDoesNotExist($junction, $junction . ' is not a directory'); + self::assertDirectoryExists($junction, $junction . ' is a directory'); + self::assertTrue($fs->removeJunction($junction), $junction . ' has been removed'); + self::assertDirectoryDoesNotExist($junction, $junction . ' is not a directory'); } public function testOverrideJunctions(): void @@ -335,19 +335,19 @@ class FilesystemTest extends TestCase $fs->junction($old_target, $junction); $fs->junction($target, $junction); - $this->assertTrue($fs->isJunction($junction), $junction.': is a junction'); - $this->assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction'); + self::assertTrue($fs->isJunction($junction), $junction.': is a junction'); + self::assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction'); //Remove junction - $this->assertTrue($fs->removeJunction($junction), $junction . ' has been removed'); + self::assertTrue($fs->removeJunction($junction), $junction . ' has been removed'); // Override broken junction $fs->junction($old_target, $junction); $fs->removeDirectory($old_target); $fs->junction($target, $junction); - $this->assertTrue($fs->isJunction($junction), $junction.': is a junction'); - $this->assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction'); + self::assertTrue($fs->isJunction($junction), $junction.': is a junction'); + self::assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction'); } public function testCopy(): void @@ -362,17 +362,17 @@ class FilesystemTest extends TestCase $fs = new Filesystem(); $result1 = $fs->copy($this->workingDir . '/foo', $this->workingDir . '/foop'); - $this->assertTrue($result1, 'Copying directory failed.'); - $this->assertDirectoryExists($this->workingDir . '/foop', 'Not a directory: ' . $this->workingDir . '/foop'); - $this->assertDirectoryExists($this->workingDir . '/foop/bar', 'Not a directory: ' . $this->workingDir . '/foop/bar'); - $this->assertDirectoryExists($this->workingDir . '/foop/baz', 'Not a directory: ' . $this->workingDir . '/foop/baz'); - $this->assertFileExists($this->workingDir . '/foop/foo.file', 'Not a file: ' . $this->workingDir . '/foop/foo.file'); - $this->assertFileExists($this->workingDir . '/foop/bar/foobar.file', 'Not a file: ' . $this->workingDir . '/foop/bar/foobar.file'); - $this->assertFileExists($this->workingDir . '/foop/baz/foobaz.file', 'Not a file: ' . $this->workingDir . '/foop/baz/foobaz.file'); + self::assertTrue($result1, 'Copying directory failed.'); + self::assertDirectoryExists($this->workingDir . '/foop', 'Not a directory: ' . $this->workingDir . '/foop'); + self::assertDirectoryExists($this->workingDir . '/foop/bar', 'Not a directory: ' . $this->workingDir . '/foop/bar'); + self::assertDirectoryExists($this->workingDir . '/foop/baz', 'Not a directory: ' . $this->workingDir . '/foop/baz'); + self::assertFileExists($this->workingDir . '/foop/foo.file', 'Not a file: ' . $this->workingDir . '/foop/foo.file'); + self::assertFileExists($this->workingDir . '/foop/bar/foobar.file', 'Not a file: ' . $this->workingDir . '/foop/bar/foobar.file'); + self::assertFileExists($this->workingDir . '/foop/baz/foobaz.file', 'Not a file: ' . $this->workingDir . '/foop/baz/foobaz.file'); $result2 = $fs->copy($this->testFile, $this->workingDir . '/testfile.file'); - $this->assertTrue($result2); - $this->assertFileExists($this->workingDir . '/testfile.file'); + self::assertTrue($result2); + self::assertFileExists($this->workingDir . '/testfile.file'); } public function testCopyThenRemove(): void @@ -387,14 +387,14 @@ class FilesystemTest extends TestCase $fs = new Filesystem(); $fs->copyThenRemove($this->testFile, $this->workingDir . '/testfile.file'); - $this->assertFileDoesNotExist($this->testFile, 'Still a file: ' . $this->testFile); + self::assertFileDoesNotExist($this->testFile, 'Still a file: ' . $this->testFile); $fs->copyThenRemove($this->workingDir . '/foo', $this->workingDir . '/foop'); - $this->assertFileDoesNotExist($this->workingDir . '/foo/baz/foobaz.file', 'Still a file: ' . $this->workingDir . '/foo/baz/foobaz.file'); - $this->assertFileDoesNotExist($this->workingDir . '/foo/bar/foobar.file', 'Still a file: ' . $this->workingDir . '/foo/bar/foobar.file'); - $this->assertFileDoesNotExist($this->workingDir . '/foo/foo.file', 'Still a file: ' . $this->workingDir . '/foo/foo.file'); - $this->assertDirectoryDoesNotExist($this->workingDir . '/foo/baz', 'Still a directory: ' . $this->workingDir . '/foo/baz'); - $this->assertDirectoryDoesNotExist($this->workingDir . '/foo/bar', 'Still a directory: ' . $this->workingDir . '/foo/bar'); - $this->assertDirectoryDoesNotExist($this->workingDir . '/foo', 'Still a directory: ' . $this->workingDir . '/foo'); + self::assertFileDoesNotExist($this->workingDir . '/foo/baz/foobaz.file', 'Still a file: ' . $this->workingDir . '/foo/baz/foobaz.file'); + self::assertFileDoesNotExist($this->workingDir . '/foo/bar/foobar.file', 'Still a file: ' . $this->workingDir . '/foo/bar/foobar.file'); + self::assertFileDoesNotExist($this->workingDir . '/foo/foo.file', 'Still a file: ' . $this->workingDir . '/foo/foo.file'); + self::assertDirectoryDoesNotExist($this->workingDir . '/foo/baz', 'Still a directory: ' . $this->workingDir . '/foo/baz'); + self::assertDirectoryDoesNotExist($this->workingDir . '/foo/bar', 'Still a directory: ' . $this->workingDir . '/foo/bar'); + self::assertDirectoryDoesNotExist($this->workingDir . '/foo', 'Still a directory: ' . $this->workingDir . '/foo'); } } diff --git a/tests/Composer/Test/Util/GitHubTest.php b/tests/Composer/Test/Util/GitHubTest.php index d9e0e5412..7ef74b934 100644 --- a/tests/Composer/Test/Util/GitHubTest.php +++ b/tests/Composer/Test/Util/GitHubTest.php @@ -55,7 +55,7 @@ class GitHubTest extends TestCase $github = new GitHub($io, $config, null, $httpDownloader); - $this->assertTrue($github->authorizeOAuthInteractively($this->origin, $this->message)); + self::assertTrue($github->authorizeOAuthInteractively($this->origin, $this->message)); } public function testUsernamePasswordFailure(): void @@ -80,7 +80,7 @@ class GitHubTest extends TestCase $github = new GitHub($io, $config, null, $httpDownloader); - $this->assertFalse($github->authorizeOAuthInteractively($this->origin)); + self::assertFalse($github->authorizeOAuthInteractively($this->origin)); } /** diff --git a/tests/Composer/Test/Util/GitLabTest.php b/tests/Composer/Test/Util/GitLabTest.php index 5c8cc9443..095cd747a 100644 --- a/tests/Composer/Test/Util/GitLabTest.php +++ b/tests/Composer/Test/Util/GitLabTest.php @@ -57,7 +57,7 @@ class GitLabTest extends TestCase $gitLab = new GitLab($io, $config, null, $httpDownloader); - $this->assertTrue($gitLab->authorizeOAuthInteractively('http', $this->origin, $this->message)); + self::assertTrue($gitLab->authorizeOAuthInteractively('http', $this->origin, $this->message)); } public function testUsernamePasswordFailure(): void diff --git a/tests/Composer/Test/Util/GitTest.php b/tests/Composer/Test/Util/GitTest.php index 9a0ec1e8f..71e064544 100644 --- a/tests/Composer/Test/Util/GitTest.php +++ b/tests/Composer/Test/Util/GitTest.php @@ -47,7 +47,7 @@ class GitTest extends TestCase public function testRunCommandPublicGitHubRepositoryNotInitialClone(string $protocol, string $expectedUrl): void { $commandCallable = function ($url) use ($expectedUrl): string { - $this->assertSame($expectedUrl, $url); + self::assertSame($expectedUrl, $url); return 'git command'; }; @@ -72,7 +72,7 @@ class GitTest extends TestCase self::expectException('RuntimeException'); $commandCallable = function ($url): string { - $this->assertSame('https://github.com/acme/repo', $url); + self::assertSame('https://github.com/acme/repo', $url); return 'git command'; }; diff --git a/tests/Composer/Test/Util/HttpDownloaderTest.php b/tests/Composer/Test/Util/HttpDownloaderTest.php index 294063902..aa550b500 100644 --- a/tests/Composer/Test/Util/HttpDownloaderTest.php +++ b/tests/Composer/Test/Util/HttpDownloaderTest.php @@ -49,7 +49,7 @@ class HttpDownloaderTest extends TestCase try { $fs->get('https://user:pass@github.com/composer/composer/404'); } catch (\Composer\Downloader\TransportException $e) { - $this->assertNotEquals(200, $e->getCode()); + self::assertNotEquals(200, $e->getCode()); } } @@ -57,7 +57,7 @@ class HttpDownloaderTest extends TestCase { $io = new BufferIO(); HttpDownloader::outputWarnings($io, '$URL', []); - $this->assertSame('', $io->getOutput()); + self::assertSame('', $io->getOutput()); HttpDownloader::outputWarnings($io, '$URL', [ 'warning' => 'old warning msg', 'warning-versions' => '>=2.0', @@ -74,7 +74,7 @@ class HttpDownloaderTest extends TestCase ]); // the tag are consumed by the OutputFormatter, but not as that is not a default output format - $this->assertSame( + self::assertSame( 'Warning from $URL: old warning msg'.PHP_EOL. 'Info from $URL: old info msg'.PHP_EOL. 'Warning from $URL: visible warning'.PHP_EOL. diff --git a/tests/Composer/Test/Util/IniHelperTest.php b/tests/Composer/Test/Util/IniHelperTest.php index fbfde3a3d..9750ab8c0 100644 --- a/tests/Composer/Test/Util/IniHelperTest.php +++ b/tests/Composer/Test/Util/IniHelperTest.php @@ -33,8 +33,8 @@ class IniHelperTest extends TestCase ]; $this->setEnv($paths); - $this->assertStringContainsString('does not exist', IniHelper::getMessage()); - $this->assertEquals($paths, IniHelper::getAll()); + self::assertStringContainsString('does not exist', IniHelper::getMessage()); + self::assertEquals($paths, IniHelper::getAll()); } public function testWithLoadedIniOnly(): void @@ -44,7 +44,7 @@ class IniHelperTest extends TestCase ]; $this->setEnv($paths); - $this->assertStringContainsString('loaded.ini', IniHelper::getMessage()); + self::assertStringContainsString('loaded.ini', IniHelper::getMessage()); } public function testWithLoadedIniAndAdditional(): void @@ -56,8 +56,8 @@ class IniHelperTest extends TestCase ]; $this->setEnv($paths); - $this->assertStringContainsString('multiple ini files', IniHelper::getMessage()); - $this->assertEquals($paths, IniHelper::getAll()); + self::assertStringContainsString('multiple ini files', IniHelper::getMessage()); + self::assertEquals($paths, IniHelper::getAll()); } public function testWithoutLoadedIniAndAdditional(): void @@ -69,8 +69,8 @@ class IniHelperTest extends TestCase ]; $this->setEnv($paths); - $this->assertStringContainsString('multiple ini files', IniHelper::getMessage()); - $this->assertEquals($paths, IniHelper::getAll()); + self::assertStringContainsString('multiple ini files', IniHelper::getMessage()); + self::assertEquals($paths, IniHelper::getAll()); } public static function setUpBeforeClass(): void diff --git a/tests/Composer/Test/Util/MetadataMinifierTest.php b/tests/Composer/Test/Util/MetadataMinifierTest.php index d0961d5fd..46e91a991 100644 --- a/tests/Composer/Test/Util/MetadataMinifierTest.php +++ b/tests/Composer/Test/Util/MetadataMinifierTest.php @@ -39,7 +39,7 @@ class MetadataMinifierTest extends TestCase $source = [$dumper->dump($package1), $dumper->dump($package2), $dumper->dump($package3)]; - $this->assertSame($minified, MetadataMinifier::minify($source)); - $this->assertSame($source, MetadataMinifier::expand($minified)); + self::assertSame($minified, MetadataMinifier::minify($source)); + self::assertSame($source, MetadataMinifier::expand($minified)); } } diff --git a/tests/Composer/Test/Util/NoProxyPatternTest.php b/tests/Composer/Test/Util/NoProxyPatternTest.php index 91c00f3ca..6e639110c 100644 --- a/tests/Composer/Test/Util/NoProxyPatternTest.php +++ b/tests/Composer/Test/Util/NoProxyPatternTest.php @@ -24,7 +24,7 @@ class NoProxyPatternTest extends TestCase { $matcher = new NoProxyPattern($noproxy); $url = $this->getUrl($url); - $this->assertEquals($expected, $matcher->test($url)); + self::assertEquals($expected, $matcher->test($url)); } public static function dataHostName(): array @@ -51,7 +51,7 @@ class NoProxyPatternTest extends TestCase { $matcher = new NoProxyPattern($noproxy); $url = $this->getUrl($url); - $this->assertEquals($expected, $matcher->test($url)); + self::assertEquals($expected, $matcher->test($url)); } public static function dataIpAddress(): array @@ -76,7 +76,7 @@ class NoProxyPatternTest extends TestCase { $matcher = new NoProxyPattern($noproxy); $url = $this->getUrl($url); - $this->assertEquals($expected, $matcher->test($url)); + self::assertEquals($expected, $matcher->test($url)); } public static function dataIpRange(): array @@ -101,7 +101,7 @@ class NoProxyPatternTest extends TestCase { $matcher = new NoProxyPattern($noproxy); $url = $this->getUrl($url); - $this->assertEquals($expected, $matcher->test($url)); + self::assertEquals($expected, $matcher->test($url)); } public static function dataPort(): array diff --git a/tests/Composer/Test/Util/PerforceTest.php b/tests/Composer/Test/Util/PerforceTest.php index 414cca112..1994675e0 100644 --- a/tests/Composer/Test/Util/PerforceTest.php +++ b/tests/Composer/Test/Util/PerforceTest.php @@ -78,7 +78,7 @@ class PerforceTest extends TestCase $client = $this->perforce->getClient(); $expected = 'composer_perforce_TEST_depot'; - $this->assertEquals($expected, $client); + self::assertEquals($expected, $client); } public function testGetClientFromStream(): void @@ -88,13 +88,13 @@ class PerforceTest extends TestCase $client = $this->perforce->getClient(); $expected = 'composer_perforce_TEST_depot_branch'; - $this->assertEquals($expected, $client); + self::assertEquals($expected, $client); } public function testGetStreamWithoutStream(): void { $stream = $this->perforce->getStream(); - $this->assertEquals("//depot", $stream); + self::assertEquals("//depot", $stream); } public function testGetStreamWithStream(): void @@ -102,26 +102,26 @@ class PerforceTest extends TestCase $this->setPerforceToStream(); $stream = $this->perforce->getStream(); - $this->assertEquals('//depot/branch', $stream); + self::assertEquals('//depot/branch', $stream); } public function testGetStreamWithoutLabelWithStreamWithoutLabel(): void { $stream = $this->perforce->getStreamWithoutLabel('//depot/branch'); - $this->assertEquals('//depot/branch', $stream); + self::assertEquals('//depot/branch', $stream); } public function testGetStreamWithoutLabelWithStreamWithLabel(): void { $stream = $this->perforce->getStreamWithoutLabel('//depot/branching@label'); - $this->assertEquals('//depot/branching', $stream); + self::assertEquals('//depot/branching', $stream); } public function testGetClientSpec(): void { $clientSpec = $this->perforce->getP4ClientSpec(); $expected = 'path/composer_perforce_TEST_depot.p4.spec'; - $this->assertEquals($expected, $clientSpec); + self::assertEquals($expected, $clientSpec); } public function testGenerateP4Command(): void @@ -129,13 +129,13 @@ class PerforceTest extends TestCase $command = 'do something'; $p4Command = $this->perforce->generateP4Command($command); $expected = 'p4 -u user -c composer_perforce_TEST_depot -p port do something'; - $this->assertEquals($expected, $p4Command); + self::assertEquals($expected, $p4Command); } public function testQueryP4UserWithUserAlreadySet(): void { $this->perforce->queryP4user(); - $this->assertEquals(self::TEST_P4USER, $this->perforce->getUser()); + self::assertEquals(self::TEST_P4USER, $this->perforce->getUser()); } public function testQueryP4UserWithUserSetInP4VariablesWithWindowsOS(): void @@ -148,7 +148,7 @@ class PerforceTest extends TestCase ); $this->perforce->queryP4user(); - $this->assertEquals('TEST_P4VARIABLE_USER', $this->perforce->getUser()); + self::assertEquals('TEST_P4VARIABLE_USER', $this->perforce->getUser()); } public function testQueryP4UserWithUserSetInP4VariablesNotWindowsOS(): void @@ -162,7 +162,7 @@ class PerforceTest extends TestCase ); $this->perforce->queryP4user(); - $this->assertEquals('TEST_P4VARIABLE_USER', $this->perforce->getUser()); + self::assertEquals('TEST_P4VARIABLE_USER', $this->perforce->getUser()); } public function testQueryP4UserQueriesForUser(): void @@ -173,7 +173,7 @@ class PerforceTest extends TestCase ->with($this->equalTo($expectedQuestion)) ->willReturn('TEST_QUERY_USER'); $this->perforce->queryP4user(); - $this->assertEquals('TEST_QUERY_USER', $this->perforce->getUser()); + self::assertEquals('TEST_QUERY_USER', $this->perforce->getUser()); } public function testQueryP4UserStoresResponseToQueryForUserWithWindows(): void @@ -228,7 +228,7 @@ class PerforceTest extends TestCase ]; $this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, $this->getMockIOInterface()); $password = $this->perforce->queryP4Password(); - $this->assertEquals('TEST_PASSWORD', $password); + self::assertEquals('TEST_PASSWORD', $password); } public function testQueryP4PasswordWithPasswordSetInP4VariablesWithWindowsOS(): void @@ -241,7 +241,7 @@ class PerforceTest extends TestCase ); $password = $this->perforce->queryP4Password(); - $this->assertEquals('TEST_P4VARIABLE_PASSWORD', $password); + self::assertEquals('TEST_P4VARIABLE_PASSWORD', $password); } public function testQueryP4PasswordWithPasswordSetInP4VariablesNotWindowsOS(): void @@ -254,7 +254,7 @@ class PerforceTest extends TestCase ); $password = $this->perforce->queryP4Password(); - $this->assertEquals('TEST_P4VARIABLE_PASSWORD', $password); + self::assertEquals('TEST_P4VARIABLE_PASSWORD', $password); } public function testQueryP4PasswordQueriesForPassword(): void @@ -266,7 +266,7 @@ class PerforceTest extends TestCase ->willReturn('TEST_QUERY_PASSWORD'); $password = $this->perforce->queryP4Password(); - $this->assertEquals('TEST_QUERY_PASSWORD', $password); + self::assertEquals('TEST_QUERY_PASSWORD', $password); } public function testWriteP4ClientSpecWithoutStream(): void @@ -282,9 +282,9 @@ class PerforceTest extends TestCase $expectedArray = $this->getExpectedClientSpec(false); try { foreach ($expectedArray as $expected) { - $this->assertStringStartsWith($expected, fgets($stream)); + self::assertStringStartsWith($expected, (string) fgets($stream)); } - $this->assertFalse(fgets($stream)); + self::assertFalse(fgets($stream)); } catch (\Exception $e) { fclose($stream); throw $e; @@ -306,9 +306,9 @@ class PerforceTest extends TestCase $expectedArray = $this->getExpectedClientSpec(true); try { foreach ($expectedArray as $expected) { - $this->assertStringStartsWith($expected, fgets($stream)); + self::assertStringStartsWith($expected, (string) fgets($stream)); } - $this->assertFalse(fgets($stream)); + self::assertFalse(fgets($stream)); } catch (\Exception $e) { fclose($stream); throw $e; @@ -354,7 +354,7 @@ class PerforceTest extends TestCase ); $branches = $this->perforce->getBranches(); - $this->assertEquals('//depot/branch@1234', $branches['master']); + self::assertEquals('//depot/branch@1234', $branches['master']); } public function testGetBranchesWithoutStream(): void @@ -370,7 +370,7 @@ class PerforceTest extends TestCase ); $branches = $this->perforce->getBranches(); - $this->assertEquals('//depot@5678', $branches['master']); + self::assertEquals('//depot@5678', $branches['master']); } public function testGetTagsWithoutStream(): void @@ -386,8 +386,8 @@ class PerforceTest extends TestCase ); $tags = $this->perforce->getTags(); - $this->assertEquals('//depot@0.0.1', $tags['0.0.1']); - $this->assertEquals('//depot@0.0.2', $tags['0.0.2']); + self::assertEquals('//depot@0.0.1', $tags['0.0.1']); + self::assertEquals('//depot@0.0.2', $tags['0.0.2']); } public function testGetTagsWithStream(): void @@ -405,15 +405,15 @@ class PerforceTest extends TestCase ); $tags = $this->perforce->getTags(); - $this->assertEquals('//depot/branch@0.0.1', $tags['0.0.1']); - $this->assertEquals('//depot/branch@0.0.2', $tags['0.0.2']); + self::assertEquals('//depot/branch@0.0.1', $tags['0.0.1']); + self::assertEquals('//depot/branch@0.0.2', $tags['0.0.2']); } public function testCheckStreamWithoutStream(): void { $result = $this->perforce->checkStream(); - $this->assertFalse($result); - $this->assertFalse($this->perforce->isStream()); + self::assertFalse($result); + self::assertFalse($this->perforce->isStream()); } public function testCheckStreamWithStream(): void @@ -429,8 +429,8 @@ class PerforceTest extends TestCase ); $result = $this->perforce->checkStream(); - $this->assertTrue($result); - $this->assertTrue($this->perforce->isStream()); + self::assertTrue($result); + self::assertTrue($this->perforce->isStream()); } public function testGetComposerInformationWithoutLabelWithoutStream(): void @@ -452,7 +452,7 @@ class PerforceTest extends TestCase 'minimum-stability' => 'dev', 'autoload' => ['psr-0' => []], ]; - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } public function testGetComposerInformationWithLabelWithoutStream(): void @@ -479,7 +479,7 @@ class PerforceTest extends TestCase 'minimum-stability' => 'dev', 'autoload' => ['psr-0' => []], ]; - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } public function testGetComposerInformationWithoutLabelWithStream(): void @@ -504,7 +504,7 @@ class PerforceTest extends TestCase 'minimum-stability' => 'dev', 'autoload' => ['psr-0' => []], ]; - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } public function testGetComposerInformationWithLabelWithStream(): void @@ -533,7 +533,7 @@ class PerforceTest extends TestCase 'minimum-stability' => 'dev', 'autoload' => ['psr-0' => []], ]; - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } public function testSyncCodeBaseWithoutStream(): void @@ -566,7 +566,7 @@ class PerforceTest extends TestCase ); $result = $this->perforce->checkServerExists('perforce.does.exist:port', $this->processExecutor); - $this->assertTrue($result); + self::assertTrue($result); } /** @@ -585,7 +585,7 @@ class PerforceTest extends TestCase ->willReturn(127); $result = $this->perforce->checkServerExists('perforce.does.exist:port', $processExecutor); - $this->assertFalse($result); + self::assertFalse($result); } public static function getComposerJson(): string diff --git a/tests/Composer/Test/Util/PlatformTest.php b/tests/Composer/Test/Util/PlatformTest.php index b6be7b897..bbaa4ec82 100644 --- a/tests/Composer/Test/Util/PlatformTest.php +++ b/tests/Composer/Test/Util/PlatformTest.php @@ -25,15 +25,15 @@ class PlatformTest extends TestCase public function testExpandPath(): void { putenv('TESTENV=/home/test'); - $this->assertEquals('/home/test/myPath', Platform::expandPath('%TESTENV%/myPath')); - $this->assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath')); - $this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test')); + self::assertEquals('/home/test/myPath', Platform::expandPath('%TESTENV%/myPath')); + self::assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath')); + self::assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test')); } public function testIsWindows(): void { // Compare 2 common tests for Windows to the built-in Windows test - $this->assertEquals(('\\' === DIRECTORY_SEPARATOR), Platform::isWindows()); - $this->assertEquals(defined('PHP_WINDOWS_VERSION_MAJOR'), Platform::isWindows()); + self::assertEquals(('\\' === DIRECTORY_SEPARATOR), Platform::isWindows()); + self::assertEquals(defined('PHP_WINDOWS_VERSION_MAJOR'), Platform::isWindows()); } } diff --git a/tests/Composer/Test/Util/ProcessExecutorTest.php b/tests/Composer/Test/Util/ProcessExecutorTest.php index a8455c7ab..006f2321f 100644 --- a/tests/Composer/Test/Util/ProcessExecutorTest.php +++ b/tests/Composer/Test/Util/ProcessExecutorTest.php @@ -29,7 +29,7 @@ class ProcessExecutorTest extends TestCase { $process = new ProcessExecutor; $process->execute('echo foo', $output); - $this->assertEquals("foo".PHP_EOL, $output); + self::assertEquals("foo".PHP_EOL, $output); } public function testExecuteOutputsIfNotCaptured(): void @@ -38,7 +38,7 @@ class ProcessExecutorTest extends TestCase ob_start(); $process->execute('echo foo'); $output = ob_get_clean(); - $this->assertEquals("foo".PHP_EOL, $output); + self::assertEquals("foo".PHP_EOL, $output); } public function testUseIOIsNotNullAndIfNotCaptured(): void @@ -56,14 +56,14 @@ class ProcessExecutorTest extends TestCase { $process = new ProcessExecutor; $process->execute('cat foo', $output); - $this->assertNotNull($process->getErrorOutput()); + self::assertStringContainsString('foo: No such file or directory', $process->getErrorOutput()); } public function testTimeout(): void { ProcessExecutor::setTimeout(1); $process = new ProcessExecutor; - $this->assertEquals(1, $process->getTimeout()); + self::assertEquals(1, $process->getTimeout()); ProcessExecutor::setTimeout(60); } @@ -74,7 +74,7 @@ class ProcessExecutorTest extends TestCase { $process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG)); $process->execute($command, $output); - $this->assertEquals('Executing command (CWD): ' . $expectedCommandOutput, trim($buffer->getOutput())); + self::assertEquals('Executing command (CWD): ' . $expectedCommandOutput, trim($buffer->getOutput())); } public static function hidePasswordProvider(): array @@ -92,18 +92,18 @@ class ProcessExecutorTest extends TestCase { $process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG)); $process->execute('echo https://localhost:1234/', $output); - $this->assertEquals('Executing command (CWD): echo https://localhost:1234/', trim($buffer->getOutput())); + self::assertEquals('Executing command (CWD): echo https://localhost:1234/', trim($buffer->getOutput())); } public function testSplitLines(): void { $process = new ProcessExecutor; - $this->assertEquals([], $process->splitLines('')); - $this->assertEquals([], $process->splitLines(null)); - $this->assertEquals(['foo'], $process->splitLines('foo')); - $this->assertEquals(['foo', 'bar'], $process->splitLines("foo\nbar")); - $this->assertEquals(['foo', 'bar'], $process->splitLines("foo\r\nbar")); - $this->assertEquals(['foo', 'bar'], $process->splitLines("foo\r\nbar\n")); + self::assertEquals([], $process->splitLines('')); + self::assertEquals([], $process->splitLines(null)); + self::assertEquals(['foo'], $process->splitLines('foo')); + self::assertEquals(['foo', 'bar'], $process->splitLines("foo\nbar")); + self::assertEquals(['foo', 'bar'], $process->splitLines("foo\r\nbar")); + self::assertEquals(['foo', 'bar'], $process->splitLines("foo\r\nbar\n")); } public function testConsoleIODoesNotFormatSymfonyConsoleStyle(): void @@ -112,7 +112,7 @@ class ProcessExecutorTest extends TestCase $process = new ProcessExecutor(new ConsoleIO(new ArrayInput([]), $output, new HelperSet([]))); $process->execute('php -ddisplay_errors=0 -derror_reporting=0 -r "echo \'foo\'.PHP_EOL;"'); - $this->assertSame('foo'.PHP_EOL, $output->fetch()); + self::assertSame('foo'.PHP_EOL, $output->fetch()); } public function testExecuteAsyncCancel(): void @@ -121,12 +121,12 @@ class ProcessExecutorTest extends TestCase $process->enableAsync(); $start = microtime(true); $promise = $process->executeAsync('sleep 2'); - $this->assertEquals(1, $process->countActiveJobs()); + self::assertEquals(1, $process->countActiveJobs()); $promise->cancel(); - $this->assertEquals(0, $process->countActiveJobs()); + self::assertEquals(0, $process->countActiveJobs()); $process->wait(); $end = microtime(true); - $this->assertTrue($end - $start < 2, 'Canceling took longer than it should, lasted '.($end - $start)); + self::assertTrue($end - $start < 2, 'Canceling took longer than it should, lasted '.($end - $start)); } /** @@ -139,7 +139,7 @@ class ProcessExecutorTest extends TestCase public function testEscapeArgument($argument, string $win, string $unix): void { $expected = defined('PHP_WINDOWS_VERSION_BUILD') ? $win : $unix; - $this->assertSame($expected, ProcessExecutor::escape($argument)); + self::assertSame($expected, ProcessExecutor::escape($argument)); } /** diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index d673cd2b0..048ccb0f8 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -34,7 +34,7 @@ class RemoteFilesystemTest extends TestCase ; $res = $this->callGetOptionsForUrl($io, ['http://example.org', []]); - $this->assertTrue(isset($res['http']['header']) && is_array($res['http']['header']), 'getOptions must return an array with headers'); + self::assertTrue(isset($res['http']['header']) && is_array($res['http']['header']), 'getOptions must return an array with headers'); } public function testGetOptionsForUrlWithAuthorization(): void @@ -59,7 +59,7 @@ class RemoteFilesystemTest extends TestCase $found = true; } } - $this->assertTrue($found, 'getOptions must have an Authorization header'); + self::assertTrue($found, 'getOptions must have an Authorization header'); } public function testGetOptionsForUrlWithStreamOptions(): void @@ -82,7 +82,7 @@ class RemoteFilesystemTest extends TestCase ]]; $res = $this->callGetOptionsForUrl($io, ['https://example.org', []], $streamOptions); - $this->assertTrue( + self::assertTrue( isset($res['ssl'], $res['ssl']['allow_self_signed']) && true === $res['ssl']['allow_self_signed'], 'getOptions must return an array with a allow_self_signed set to true' ); @@ -108,7 +108,7 @@ class RemoteFilesystemTest extends TestCase ]]; $res = $this->callGetOptionsForUrl($io, ['https://example.org', $streamOptions]); - $this->assertTrue(isset($res['http']['header']), 'getOptions must return an array with a http.header key'); + self::assertTrue(isset($res['http']['header']), 'getOptions must return an array with a http.header key'); $found = false; foreach ($res['http']['header'] as $header) { @@ -117,15 +117,15 @@ class RemoteFilesystemTest extends TestCase } } - $this->assertTrue($found, 'getOptions must have a Foo: bar header'); - $this->assertGreaterThan(1, count($res['http']['header'])); + self::assertTrue($found, 'getOptions must have a Foo: bar header'); + self::assertGreaterThan(1, count($res['http']['header'])); } public function testCallbackGetFileSize(): void { $fs = new RemoteFilesystem($this->getIOInterfaceMock(), $this->getConfigMock()); $this->callCallbackGet($fs, STREAM_NOTIFY_FILE_SIZE_IS, 0, '', 0, 0, 20); - $this->assertAttributeEqualsCustom(20, 'bytesMax', $fs); + self::assertAttributeEqualsCustom(20, 'bytesMax', $fs); } public function testCallbackGetNotifyProgress(): void @@ -141,22 +141,24 @@ class RemoteFilesystemTest extends TestCase $this->setAttribute($fs, 'progress', true); $this->callCallbackGet($fs, STREAM_NOTIFY_PROGRESS, 0, '', 0, 10, 20); - $this->assertAttributeEqualsCustom(50, 'lastProgress', $fs); + self::assertAttributeEqualsCustom(50, 'lastProgress', $fs); } + /** + * @doesNotPerformAssertions + */ public function testCallbackGetPassesThrough404(): void { $fs = new RemoteFilesystem($this->getIOInterfaceMock(), $this->getConfigMock()); $this->callCallbackGet($fs, STREAM_NOTIFY_FAILURE, 0, 'HTTP/1.1 404 Not Found', 404, 0, 0); - $this->assertTrue(true, 'callbackGet must pass through 404'); } public function testGetContents(): void { $fs = new RemoteFilesystem($this->getIOInterfaceMock(), $this->getConfigMock()); - $this->assertStringContainsString('testGetContents', $fs->getContents('http://example.org', 'file://'.__FILE__)); + self::assertStringContainsString('testGetContents', (string) $fs->getContents('http://example.org', 'file://'.__FILE__)); } public function testCopy(): void @@ -164,9 +166,9 @@ class RemoteFilesystemTest extends TestCase $fs = new RemoteFilesystem($this->getIOInterfaceMock(), $this->getConfigMock()); $file = $this->createTempFile(); - $this->assertTrue($fs->copy('http://example.org', 'file://'.__FILE__, $file)); - $this->assertFileExists($file); - $this->assertStringContainsString('testCopy', file_get_contents($file)); + self::assertTrue($fs->copy('http://example.org', 'file://'.__FILE__, $file)); + self::assertFileExists($file); + self::assertStringContainsString('testCopy', (string) file_get_contents($file)); unlink($file); } @@ -231,9 +233,9 @@ class RemoteFilesystemTest extends TestCase ['retry-auth-failure' => true] ); - $this->assertTrue($copyResult); - $this->assertFileExists($file); - $this->assertStringContainsString('Copied', file_get_contents($file)); + self::assertTrue($copyResult); + self::assertFileExists($file); + self::assertStringContainsString('Copied', (string) file_get_contents($file)); unlink($file); } @@ -247,16 +249,16 @@ class RemoteFilesystemTest extends TestCase $res = $this->callGetOptionsForUrl($io, ['example.org', ['ssl' => ['cafile' => '/some/path/file.crt']]], [], 'http://www.example.org'); - $this->assertTrue(isset($res['ssl']['ciphers'])); - $this->assertMatchesRegularExpression('|!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA|', $res['ssl']['ciphers']); - $this->assertTrue($res['ssl']['verify_peer']); - $this->assertTrue($res['ssl']['SNI_enabled']); - $this->assertEquals(7, $res['ssl']['verify_depth']); - $this->assertEquals('/some/path/file.crt', $res['ssl']['cafile']); + self::assertTrue(isset($res['ssl']['ciphers'])); + self::assertMatchesRegularExpression('|!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA|', $res['ssl']['ciphers']); + self::assertTrue($res['ssl']['verify_peer']); + self::assertTrue($res['ssl']['SNI_enabled']); + self::assertEquals(7, $res['ssl']['verify_depth']); + self::assertEquals('/some/path/file.crt', $res['ssl']['cafile']); if (version_compare(PHP_VERSION, '5.4.13') >= 0) { - $this->assertTrue($res['ssl']['disable_compression']); + self::assertTrue($res['ssl']['disable_compression']); } else { - $this->assertFalse(isset($res['ssl']['disable_compression'])); + self::assertFalse(isset($res['ssl']['disable_compression'])); } } @@ -291,7 +293,7 @@ class RemoteFilesystemTest extends TestCase $result = $rfs->getContents($hostname, $url, false); - $this->assertEquals($contents, $result); + self::assertEquals($contents, $result); } /** @@ -331,8 +333,8 @@ class RemoteFilesystemTest extends TestCase $result = $rfs->getContents($hostname, $url, false); - $this->assertEquals($contents, $result); - $this->assertEquals(['bitbucket.org', 'bbuseruploads.s3.amazonaws.com'], $domains); + self::assertEquals($contents, $result); + self::assertEquals(['bitbucket.org', 'bbuseruploads.s3.amazonaws.com'], $domains); } /** @@ -399,7 +401,7 @@ class RemoteFilesystemTest extends TestCase { $attr = new ReflectionProperty($object, $attribute); $attr->setAccessible(true); - $this->assertSame($value, $attr->getValue($object)); + self::assertSame($value, $attr->getValue($object)); } /** diff --git a/tests/Composer/Test/Util/SilencerTest.php b/tests/Composer/Test/Util/SilencerTest.php index 9161dae60..270b9b111 100644 --- a/tests/Composer/Test/Util/SilencerTest.php +++ b/tests/Composer/Test/Util/SilencerTest.php @@ -40,10 +40,10 @@ class SilencerTest extends TestCase return $a * $b * $c; }, 2, 3, 4); - $this->assertEquals(24, $result); + self::assertEquals(24, $result); // Check the error reporting setting was restored correctly - $this->assertEquals($before, error_reporting()); + self::assertEquals($before, error_reporting()); } /** diff --git a/tests/Composer/Test/Util/StreamContextFactoryTest.php b/tests/Composer/Test/Util/StreamContextFactoryTest.php index 4d875122d..d1fe5db31 100644 --- a/tests/Composer/Test/Util/StreamContextFactoryTest.php +++ b/tests/Composer/Test/Util/StreamContextFactoryTest.php @@ -45,8 +45,8 @@ class StreamContextFactoryTest extends TestCase $options = stream_context_get_options($context); $params = stream_context_get_params($context); - $this->assertEquals($expectedOptions, $options); - $this->assertEquals($expectedParams, $params); + self::assertEquals($expectedOptions, $options); + self::assertEquals($expectedParams, $params); } public static function dataGetContext(): array @@ -72,7 +72,7 @@ class StreamContextFactoryTest extends TestCase $context = StreamContextFactory::getContext('http://example.org', ['http' => ['method' => 'GET', 'header' => 'User-Agent: foo']]); $options = stream_context_get_options($context); - $this->assertEquals(['http' => [ + self::assertEquals(['http' => [ 'proxy' => 'tcp://proxyserver.net:3128', 'request_fulluri' => true, 'method' => 'GET', @@ -90,7 +90,7 @@ class StreamContextFactoryTest extends TestCase $context = StreamContextFactory::getContext('http://example.org', ['http' => ['method' => 'GET', 'header' => 'User-Agent: foo']]); $options = stream_context_get_options($context); - $this->assertEquals(['http' => [ + self::assertEquals(['http' => [ 'method' => 'GET', 'max_redirects' => 20, 'follow_location' => 1, @@ -106,7 +106,7 @@ class StreamContextFactoryTest extends TestCase $context = StreamContextFactory::getContext('http://example.org', ['http' => ['method' => 'GET', 'header' => 'User-Agent: foo']]); $options = stream_context_get_options($context); - $this->assertEquals(['http' => [ + self::assertEquals(['http' => [ 'method' => 'GET', 'max_redirects' => 20, 'follow_location' => 1, @@ -121,7 +121,7 @@ class StreamContextFactoryTest extends TestCase $context = StreamContextFactory::getContext('http://example.org', ['http' => ['method' => 'GET', 'header' => ['User-Agent: foo', "X-Foo: bar"], 'request_fulluri' => false]]); $options = stream_context_get_options($context); - $this->assertEquals(['http' => [ + self::assertEquals(['http' => [ 'proxy' => 'tcp://proxyserver.net:3128', 'request_fulluri' => false, 'method' => 'GET', @@ -138,7 +138,7 @@ class StreamContextFactoryTest extends TestCase $context = StreamContextFactory::getContext('https://example.org', ['http' => ['method' => 'GET', 'header' => 'User-Agent: foo']]); $options = stream_context_get_options($context); - $this->assertEquals(['http' => [ + self::assertEquals(['http' => [ 'proxy' => 'tcp://proxyserver.net:80', 'method' => 'GET', 'header' => ['User-Agent: foo', "Proxy-Authorization: Basic " . base64_encode('username:password')], @@ -172,7 +172,7 @@ class StreamContextFactoryTest extends TestCase $context = StreamContextFactory::getContext('http://example.org', ['http' => ['header' => 'User-Agent: foo']]); $options = stream_context_get_options($context); - $this->assertEquals(['http' => [ + self::assertEquals(['http' => [ 'proxy' => $expected, 'request_fulluri' => true, 'max_redirects' => 20, @@ -184,7 +184,7 @@ class StreamContextFactoryTest extends TestCase StreamContextFactory::getContext('http://example.org'); $this->fail(); } catch (\RuntimeException $e) { - $this->assertInstanceOf('Composer\Downloader\TransportException', $e); + self::assertInstanceOf('Composer\Downloader\TransportException', $e); } } } @@ -216,7 +216,7 @@ class StreamContextFactoryTest extends TestCase ]; $context = StreamContextFactory::getContext('http://example.org', $options); $ctxoptions = stream_context_get_options($context); - $this->assertEquals(end($expectedOptions['http']['header']), end($ctxoptions['http']['header'])); + self::assertEquals(end($expectedOptions['http']['header']), end($ctxoptions['http']['header'])); } public function testInitOptionsDoesIncludeProxyAuthHeaders(): void @@ -227,7 +227,7 @@ class StreamContextFactoryTest extends TestCase $options = StreamContextFactory::initOptions('https://example.org', $options); $headers = implode(' ', $options['http']['header']); - $this->assertTrue(false !== stripos($headers, 'Proxy-Authorization')); + self::assertTrue(false !== stripos($headers, 'Proxy-Authorization')); } public function testInitOptionsForCurlDoesNotIncludeProxyAuthHeaders(): void @@ -242,6 +242,6 @@ class StreamContextFactoryTest extends TestCase $options = StreamContextFactory::initOptions('https://example.org', $options, true); $headers = implode(' ', $options['http']['header']); - $this->assertFalse(stripos($headers, 'Proxy-Authorization')); + self::assertFalse(stripos($headers, 'Proxy-Authorization')); } } diff --git a/tests/Composer/Test/Util/SvnTest.php b/tests/Composer/Test/Util/SvnTest.php index cf9f5f0ad..044bf2eed 100644 --- a/tests/Composer/Test/Util/SvnTest.php +++ b/tests/Composer/Test/Util/SvnTest.php @@ -33,7 +33,7 @@ class SvnTest extends TestCase $reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString'); $reflMethod->setAccessible(true); - $this->assertEquals($expect, $reflMethod->invoke($svn)); + self::assertEquals($expect, $reflMethod->invoke($svn)); } public static function urlProvider(): array @@ -53,7 +53,7 @@ class SvnTest extends TestCase $reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCommand'); $reflMethod->setAccessible(true); - $this->assertEquals( + self::assertEquals( self::getCmd("svn ls --non-interactive -- 'http://svn.example.org'"), $reflMethod->invokeArgs($svn, ['svn ls', $url]) ); @@ -76,7 +76,7 @@ class SvnTest extends TestCase $reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString'); $reflMethod->setAccessible(true); - $this->assertEquals(self::getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn)); + self::assertEquals(self::getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn)); } public function testCredentialsFromConfigWithCacheCredentialsTrue(): void @@ -99,7 +99,7 @@ class SvnTest extends TestCase $reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString'); $reflMethod->setAccessible(true); - $this->assertEquals(self::getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn)); + self::assertEquals(self::getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn)); } public function testCredentialsFromConfigWithCacheCredentialsFalse(): void @@ -122,6 +122,6 @@ class SvnTest extends TestCase $reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString'); $reflMethod->setAccessible(true); - $this->assertEquals(self::getCmd(" --no-auth-cache --username 'foo' --password 'bar' "), $reflMethod->invoke($svn)); + self::assertEquals(self::getCmd(" --no-auth-cache --username 'foo' --password 'bar' "), $reflMethod->invoke($svn)); } } diff --git a/tests/Composer/Test/Util/TarTest.php b/tests/Composer/Test/Util/TarTest.php index 86c7564cd..cba1d501b 100644 --- a/tests/Composer/Test/Util/TarTest.php +++ b/tests/Composer/Test/Util/TarTest.php @@ -24,13 +24,13 @@ class TarTest extends TestCase { $result = Tar::getComposerJson(__DIR__.'/Fixtures/Tar/invalid.zip'); - $this->assertNull($result); + self::assertNull($result); } public function testReturnsNullIfTheTarIsEmpty(): void { $result = Tar::getComposerJson(__DIR__.'/Fixtures/Tar/empty.tar.gz'); - $this->assertNull($result); + self::assertNull($result); } public function testThrowsExceptionIfTheTarHasNoComposerJson(): void @@ -48,13 +48,13 @@ class TarTest extends TestCase public function testReturnsComposerJsonInTarRoot(): void { $result = Tar::getComposerJson(__DIR__.'/Fixtures/Tar/root.tar.gz'); - $this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); + self::assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); } public function testReturnsComposerJsonInFirstFolder(): void { $result = Tar::getComposerJson(__DIR__.'/Fixtures/Tar/folder.tar.gz'); - $this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); + self::assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); } public function testMultipleTopLevelDirsIsInvalid(): void diff --git a/tests/Composer/Test/Util/TlsHelperTest.php b/tests/Composer/Test/Util/TlsHelperTest.php index 58144a425..64c0c4cc5 100644 --- a/tests/Composer/Test/Util/TlsHelperTest.php +++ b/tests/Composer/Test/Util/TlsHelperTest.php @@ -31,11 +31,11 @@ class TlsHelperTest extends TestCase $result = TlsHelper::checkCertificateHost($certificate, $hostname, $foundCn); if (true === $expectedResult) { - $this->assertTrue($result); - $this->assertSame($expectedCn, $foundCn); + self::assertTrue($result); + self::assertSame($expectedCn, $foundCn); } else { - $this->assertFalse($result); - $this->assertNull($foundCn); + self::assertFalse($result); + self::assertNull($foundCn); } } @@ -74,8 +74,8 @@ class TlsHelperTest extends TestCase $names = TlsHelper::getCertificateNames($certificate); self::assertIsArray($names); - $this->assertSame('example.net', $names['cn']); - $this->assertSame([ + self::assertSame('example.net', $names['cn']); + self::assertSame([ 'example.com', 'getcomposer.org', 'composer.example.org', diff --git a/tests/Composer/Test/Util/UrlTest.php b/tests/Composer/Test/Util/UrlTest.php index 267b1c1bd..04167904f 100644 --- a/tests/Composer/Test/Util/UrlTest.php +++ b/tests/Composer/Test/Util/UrlTest.php @@ -29,7 +29,7 @@ class UrlTest extends TestCase $config = new Config(); $config->merge(['config' => $conf]); - $this->assertSame($expectedUrl, Url::updateDistReference($config, $url, $ref)); + self::assertSame($expectedUrl, Url::updateDistReference($config, $url, $ref)); } public static function distRefsProvider(): array @@ -67,7 +67,7 @@ class UrlTest extends TestCase */ public function testSanitize(string $expected, string $url): void { - $this->assertSame($expected, Url::sanitize($url)); + self::assertSame($expected, Url::sanitize($url)); } public static function sanitizeProvider(): array diff --git a/tests/Composer/Test/Util/ZipTest.php b/tests/Composer/Test/Util/ZipTest.php index 0af7ea89a..b1981de86 100644 --- a/tests/Composer/Test/Util/ZipTest.php +++ b/tests/Composer/Test/Util/ZipTest.php @@ -40,7 +40,7 @@ class ZipTest extends TestCase $result = Zip::getComposerJson(__DIR__.'/Fixtures/Zip/invalid.zip'); - $this->assertNull($result); + self::assertNull($result); } public function testReturnsNullIfTheZipIsEmpty(): void @@ -51,7 +51,7 @@ class ZipTest extends TestCase $result = Zip::getComposerJson(__DIR__.'/Fixtures/Zip/empty.zip'); - $this->assertNull($result); + self::assertNull($result); } public function testThrowsExceptionIfTheZipHasNoComposerJson(): void @@ -86,7 +86,7 @@ class ZipTest extends TestCase $result = Zip::getComposerJson(__DIR__.'/Fixtures/Zip/root.zip'); - $this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); + self::assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); } public function testReturnsComposerJsonInFirstFolder(): void @@ -96,7 +96,7 @@ class ZipTest extends TestCase } $result = Zip::getComposerJson(__DIR__.'/Fixtures/Zip/folder.zip'); - $this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); + self::assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); } public function testMultipleTopLevelDirsIsInvalid(): void @@ -119,6 +119,6 @@ class ZipTest extends TestCase $result = Zip::getComposerJson(__DIR__.'/Fixtures/Zip/single-sub.zip'); - $this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); + self::assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); } }