1
0
Fork 0

PHPStan/tests updates (#11996)

* Remove a bunch of inline ignores and migrate all PHPUnit assertions to static calls

* Update baseline (1573, 93)

* Update commit hash
pull/12001/head
Jordi Boggiano 2024-05-29 23:12:06 +02:00 committed by GitHub
parent dd8af946fd
commit 37d722e73c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
141 changed files with 1342 additions and 1382 deletions

View File

@ -26,7 +26,7 @@
"composer/ca-bundle": "^1.0", "composer/ca-bundle": "^1.0",
"composer/class-map-generator": "^1.0", "composer/class-map-generator": "^1.0",
"composer/metadata-minifier": "^1.0", "composer/metadata-minifier": "^1.0",
"composer/semver": "^3.2.5", "composer/semver": "^3.3",
"composer/spdx-licenses": "^1.5.7", "composer/spdx-licenses": "^1.5.7",
"composer/xdebug-handler": "^2.0.2 || ^3.0.3", "composer/xdebug-handler": "^2.0.2 || ^3.0.3",
"justinrainbow/json-schema": "^5.2.11", "justinrainbow/json-schema": "^5.2.11",

2
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "213c5ab8912ca04b1f7a77c008875ccc", "content-hash": "9cc98d4fd8dcc30565a6570841b7ec85",
"packages": [ "packages": [
{ {
"name": "composer/ca-bundle", "name": "composer/ca-bundle",

View File

@ -4018,11 +4018,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Util/Http/CurlDownloader.php 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\\.$#" message: "#^Only booleans are allowed in a negated boolean, string given\\.$#"
count: 1 count: 1
@ -4758,11 +4753,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/AllFunctionalTest.php 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\\(\\)\\.$#" message: "#^Dynamic call to static method Composer\\\\Test\\\\TestCase\\:\\:ensureDirectoryExistsAndClear\\(\\)\\.$#"
count: 1 count: 1
@ -4941,16 +4931,6 @@ parameters:
count: 3 count: 3
path: ../tests/Composer/Test/Installer/BinaryInstallerTest.php 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\\.$#" message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 9 count: 9
@ -5021,11 +5001,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/Json/JsonManipulatorTest.php 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\\}\\.$#" 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 count: 2
@ -5091,11 +5066,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/Package/Dumper/ArrayDumperTest.php 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\\.$#" message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#"
count: 1 count: 1
@ -5156,11 +5126,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/Repository/PathRepositoryTest.php 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\\.$#" message: "#^Parameter \\#1 \\$objectOrValue of method ReflectionProperty\\:\\:setValue\\(\\) expects object\\|null, object\\|string given\\.$#"
count: 1 count: 1
@ -5231,31 +5196,16 @@ parameters:
count: 2 count: 2
path: ../tests/Composer/Test/Util/PerforceTest.php 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\\.$#" message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 1 count: 1
path: ../tests/Composer/Test/Util/PlatformTest.php 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\\(\\)\\.$#" message: "#^Dynamic call to static method Composer\\\\Util\\\\ProcessExecutor\\:\\:getTimeout\\(\\)\\.$#"
count: 1 count: 1
path: ../tests/Composer/Test/Util/ProcessExecutorTest.php 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\\.$#" message: "#^Parameter \\#1 \\$object of method ReflectionProperty\\:\\:getValue\\(\\) expects object, object\\|string given\\.$#"
count: 1 count: 1
@ -5271,16 +5221,6 @@ parameters:
count: 2 count: 2
path: ../tests/Composer/Test/Util/RemoteFilesystemTest.php 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\\.$#" message: "#^Implicit array creation is not allowed \\- variable \\$certificate does not exist\\.$#"
count: 2 count: 2

View File

@ -538,10 +538,7 @@ class Installer
return $exitCode; return $exitCode;
} }
// exists as of composer/semver 3.3.0 \Composer\Semver\CompilingMatcher::clear();
if (method_exists('Composer\Semver\CompilingMatcher', 'clear')) { // @phpstan-ignore function.alreadyNarrowedType
\Composer\Semver\CompilingMatcher::clear();
}
// write lock // write lock
$platformReqs = $this->extractPlatformRequirements($this->package->getRequires()); $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());

View File

@ -432,8 +432,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$uniques = []; $uniques = [];
foreach ($names as $name) { foreach ($names as $name) {
// @phpstan-ignore argument.type $uniques[explode('/', $name, 2)[0]] = true;
$uniques[substr($name, 0, strpos($name, '/'))] = true;
} }
$vendors = array_keys($uniques); $vendors = array_keys($uniques);

View File

@ -176,12 +176,13 @@ class CurlDownloader
} }
$errorMessage = ''; $errorMessage = '';
// @phpstan-ignore argument.type set_error_handler(static function (int $code, string $msg) use (&$errorMessage): bool {
set_error_handler(static function ($code, $msg) use (&$errorMessage): void {
if ($errorMessage) { if ($errorMessage) {
$errorMessage .= "\n"; $errorMessage .= "\n";
} }
$errorMessage .= Preg::replace('{^fopen\(.*?\): }', '', $msg); $errorMessage .= Preg::replace('{^fopen\(.*?\): }', '', $msg);
return true;
}); });
$bodyHandle = fopen($bodyTarget, 'w+b'); $bodyHandle = fopen($bodyTarget, 'w+b');
restore_error_handler(); restore_error_handler();

View File

@ -101,8 +101,7 @@ class Response
*/ */
public function collect(): void public function collect(): void
{ {
/** @phpstan-ignore assign.propertyType, assign.propertyType, assign.propertyType */ unset($this->request, $this->code, $this->headers, $this->body);
$this->request = $this->code = $this->headers = $this->body = null;
} }
/** /**

View File

@ -158,8 +158,8 @@ Found 2 abandoned packages:
} }
$auditor = new Auditor(); $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); $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); self::assertSame($expected, $result);
$this->assertSame($output, trim(str_replace("\r", '', $io->getOutput()))); self::assertSame($output, trim(str_replace("\r", '', $io->getOutput())));
} }
public function ignoredIdsProvider(): \Generator { public function ignoredIdsProvider(): \Generator {
@ -311,7 +311,7 @@ Found 2 abandoned packages:
$auditor = new Auditor(); $auditor = new Auditor();
$result = $auditor->audit($io = $this->getIOMock(), $this->getRepoSet(), $packages, Auditor::FORMAT_PLAIN, false, $ignoredIds); $result = $auditor->audit($io = $this->getIOMock(), $this->getRepoSet(), $packages, Auditor::FORMAT_PLAIN, false, $ignoredIds);
$io->expects($expectedOutput, true); $io->expects($expectedOutput, true);
$this->assertSame($exitCode, $result); self::assertSame($exitCode, $result);
} }
private function getRepoSet(): RepositorySet private function getRepoSet(): RepositorySet

View File

@ -93,7 +93,7 @@ class AllFunctionalTest extends TestCase
$this->fail($proc->getOutput()); $this->fail($proc->getOutput());
} }
$this->assertFileExists(self::$pharPath); self::assertFileExists(self::$pharPath);
copy(self::$pharPath, __DIR__.'/../../composer-test.phar'); copy(self::$pharPath, __DIR__.'/../../composer-test.phar');
} }
@ -164,16 +164,16 @@ class AllFunctionalTest extends TestCase
} }
} }
if (isset($testData['EXPECT-REGEX'])) { 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'])) { if (isset($testData['EXPECT-REGEXES'])) {
$cleanOutput = $this->cleanOutput($output); $cleanOutput = $this->cleanOutput($output);
foreach (explode("\n", $testData['EXPECT-REGEXES']) as $regex) { 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'])) { if (isset($testData['EXPECT-EXIT-CODE'])) {
$this->assertSame($testData['EXPECT-EXIT-CODE'], $exitCode); self::assertSame($testData['EXPECT-EXIT-CODE'], $exitCode);
} }
} }

View File

@ -49,7 +49,7 @@ class ApplicationTest extends TestCase
$application->doRun(new ArrayInput(['command' => 'about']), $output); $application->doRun(new ArrayInput(['command' => 'about']), $output);
$expectedOutput = sprintf('<warning>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.</warning>', $_SERVER['PHP_SELF']).PHP_EOL; $expectedOutput = sprintf('<warning>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.</warning>', $_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(); $output = new BufferedOutput();
$application->doRun(new ArrayInput(['command' => 'self-update']), $output); $application->doRun(new ArrayInput(['command' => 'self-update']), $output);
$this->assertSame('', $output->fetch()); self::assertSame('', $output->fetch());
} }
} }

View File

@ -210,13 +210,13 @@ class AutoloadGeneratorTest extends TestCase
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
// Assert that autoload_namespaces.php was correctly generated. // 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. // 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. // 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 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'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
// check standard autoload // check standard autoload
$this->assertAutoloadFiles('main5', $this->vendorDir.'/composer'); self::assertAutoloadFiles('main5', $this->vendorDir.'/composer');
$this->assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap'); self::assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap');
// make sure dev autoload is correctly dumped // 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 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'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
// check standard autoload // check standard autoload
$this->assertAutoloadFiles('main4', $this->vendorDir.'/composer'); self::assertAutoloadFiles('main4', $this->vendorDir.'/composer');
$this->assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap'); self::assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap');
// make sure dev autoload is disabled when dev mode is set to false // 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 public function testVendorDirSameAsWorkingDir(): void
@ -316,9 +316,9 @@ class AutoloadGeneratorTest extends TestCase
file_put_contents($this->vendorDir.'/composersrc/foo.php', '<?php class ClassMapFoo {}'); file_put_contents($this->vendorDir.'/composersrc/foo.php', '<?php class ClassMapFoo {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_2'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_2');
$this->assertAutoloadFiles('main3', $this->vendorDir.'/composer'); self::assertAutoloadFiles('main3', $this->vendorDir.'/composer');
$this->assertAutoloadFiles('psr4_3', $this->vendorDir.'/composer', 'psr4'); self::assertAutoloadFiles('psr4_3', $this->vendorDir.'/composer', 'psr4');
$this->assertAutoloadFiles('classmap3', $this->vendorDir.'/composer', 'classmap'); self::assertAutoloadFiles('classmap3', $this->vendorDir.'/composer', 'classmap');
} }
public function testRootPackageAutoloadingAlternativeVendorDir(): void public function testRootPackageAutoloadingAlternativeVendorDir(): void
@ -345,9 +345,9 @@ class AutoloadGeneratorTest extends TestCase
$this->fs->ensureDirectoryExists($this->workingDir.'/composersrc'); $this->fs->ensureDirectoryExists($this->workingDir.'/composersrc');
file_put_contents($this->workingDir.'/composersrc/foo.php', '<?php class ClassMapFoo {}'); file_put_contents($this->workingDir.'/composersrc/foo.php', '<?php class ClassMapFoo {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_3'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_3');
$this->assertAutoloadFiles('main2', $this->vendorDir.'/composer'); self::assertAutoloadFiles('main2', $this->vendorDir.'/composer');
$this->assertAutoloadFiles('psr4_2', $this->vendorDir.'/composer', 'psr4'); self::assertAutoloadFiles('psr4_2', $this->vendorDir.'/composer', 'psr4');
$this->assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap'); self::assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap');
} }
public function testRootPackageAutoloadingWithTargetDir(): void public function testRootPackageAutoloadingWithTargetDir(): void
@ -374,11 +374,11 @@ class AutoloadGeneratorTest extends TestCase
file_put_contents($this->workingDir.'/bar.php', '<?php class FilesBar {}'); file_put_contents($this->workingDir.'/bar.php', '<?php class FilesBar {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'TargetDir'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'TargetDir');
$this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_target_dir.php', $this->vendorDir.'/autoload.php'); self::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'); self::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'); self::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'); self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_files_target_dir.php', $this->vendorDir.'/composer/autoload_files.php');
$this->assertAutoloadFiles('classmap6', $this->vendorDir.'/composer', 'classmap'); self::assertAutoloadFiles('classmap6', $this->vendorDir.'/composer', 'classmap');
} }
public function testDuplicateFilesWarning(): void public function testDuplicateFilesWarning(): void
@ -431,8 +431,8 @@ class AutoloadGeneratorTest extends TestCase
$this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src'); $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5');
$this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); self::assertAutoloadFiles('vendors', $this->vendorDir.'/composer');
$this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty.");
} }
public function testVendorsAutoloadingWithMetapackages(): void public function testVendorsAutoloadingWithMetapackages(): void
@ -465,8 +465,8 @@ class AutoloadGeneratorTest extends TestCase
$this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/lib'); $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/lib');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5');
$this->assertAutoloadFiles('vendors_meta', $this->vendorDir.'/composer'); self::assertAutoloadFiles('vendors_meta', $this->vendorDir.'/composer');
$this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty.");
} }
public function testNonDevAutoloadExclusionWithRecursion(): void public function testNonDevAutoloadExclusionWithRecursion(): void
@ -498,8 +498,8 @@ class AutoloadGeneratorTest extends TestCase
$this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src'); $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5');
$this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); self::assertAutoloadFiles('vendors', $this->vendorDir.'/composer');
$this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty.");
} }
public function testNonDevAutoloadShouldIncludeReplacedPackages(): void 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->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', 'B\\C\\C' => $this->vendorDir.'/b/b/src/C/C.php',
'Composer\\InstalledVersions' => $this->vendorDir . '/composer/InstalledVersions.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->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5');
$this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer'); self::assertAutoloadFiles('vendors', $this->vendorDir.'/composer');
$this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated, even if empty.");
} }
public function testNonDevAutoloadReplacesNestedRequirements(): void 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->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 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->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, 'Phar');
$this->assertAutoloadFiles('phar', $this->vendorDir . '/composer'); self::assertAutoloadFiles('phar', $this->vendorDir . '/composer');
$this->assertAutoloadFiles('phar_psr4', $this->vendorDir . '/composer', 'psr4'); self::assertAutoloadFiles('phar_psr4', $this->vendorDir . '/composer', 'psr4');
$this->assertAutoloadFiles('phar_static', $this->vendorDir . '/composer', 'static'); self::assertAutoloadFiles('phar_static', $this->vendorDir . '/composer', 'static');
} }
public function testPSRToClassMapIgnoresNonExistingDir(): void public function testPSRToClassMapIgnoresNonExistingDir(): void
@ -676,8 +676,8 @@ class AutoloadGeneratorTest extends TestCase
->will($this->returnValue([])); ->will($this->returnValue([]));
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8'); $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."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( self::assertEquals(
[ [
'Composer\\InstalledVersions' => $this->vendorDir.'/composer/InstalledVersions.php', 'Composer\\InstalledVersions' => $this->vendorDir.'/composer/InstalledVersions.php',
], ],
@ -706,7 +706,7 @@ class AutoloadGeneratorTest extends TestCase
file_put_contents($this->workingDir.'/psr4/badfile.php', '<?php namespace psr4; class badclass {}'); file_put_contents($this->workingDir.'/psr4/badfile.php', '<?php namespace psr4; class badclass {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); $this->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 = <<<EOF $expectedClassmap = <<<EOF
<?php <?php
@ -723,7 +723,7 @@ return array(
); );
EOF; EOF;
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap);
} }
public function testVendorsClassMapAutoloading(): void public function testVendorsClassMapAutoloading(): void
@ -753,8 +753,8 @@ EOF;
file_put_contents($this->vendorDir.'/b/b/lib/c.php', '<?php class ClassMapBaz {}'); file_put_contents($this->vendorDir.'/b/b/lib/c.php', '<?php class ClassMapBaz {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6'); $this->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."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( self::assertEquals(
[ [
'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php', 'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php',
'ClassMapBaz' => $this->vendorDir.'/b/b/lib/c.php', 'ClassMapBaz' => $this->vendorDir.'/b/b/lib/c.php',
@ -763,7 +763,7 @@ EOF;
], ],
include $this->vendorDir.'/composer/autoload_classmap.php' 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 public function testVendorsClassMapAutoloadingWithTargetDir(): void
@ -794,8 +794,8 @@ EOF;
file_put_contents($this->vendorDir.'/b/b/src/c.php', '<?php class ClassMapBaz {}'); file_put_contents($this->vendorDir.'/b/b/src/c.php', '<?php class ClassMapBaz {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6'); $this->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."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( self::assertEquals(
[ [
'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php', 'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php',
'ClassMapBaz' => $this->vendorDir.'/b/b/src/c.php', 'ClassMapBaz' => $this->vendorDir.'/b/b/src/c.php',
@ -836,8 +836,8 @@ EOF;
file_put_contents($this->vendorDir.'/c/c/foo/test.php', '<?php class ClassMapBaz {}'); file_put_contents($this->vendorDir.'/c/c/foo/test.php', '<?php class ClassMapBaz {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); $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."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( self::assertEquals(
[ [
'ClassMapBar' => $this->vendorDir.'/b/b/test.php', 'ClassMapBar' => $this->vendorDir.'/b/b/test.php',
'ClassMapBaz' => $this->vendorDir.'/c/c/foo/test.php', 'ClassMapBaz' => $this->vendorDir.'/c/c/foo/test.php',
@ -846,9 +846,9 @@ EOF;
], ],
include $this->vendorDir.'/composer/autoload_classmap.php' include $this->vendorDir.'/composer/autoload_classmap.php'
); );
$this->assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap'); self::assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap');
$this->assertStringNotContainsString('$loader->setClassMapAuthoritative(true);', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php')); self::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::assertStringNotContainsString('$loader->setApcuPrefix(', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
} }
public function testClassMapAutoloadingAuthoritativeAndApcu(): void public function testClassMapAutoloadingAuthoritativeAndApcu(): void
@ -884,8 +884,8 @@ EOF;
$this->generator->setApcu(true); $this->generator->setApcu(true);
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); $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."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( self::assertEquals(
[ [
'ClassMapBar' => $this->vendorDir.'/b/b/ClassMapBar.php', 'ClassMapBar' => $this->vendorDir.'/b/b/ClassMapBar.php',
'ClassMapBaz' => $this->vendorDir.'/c/c/foo/ClassMapBaz.php', 'ClassMapBaz' => $this->vendorDir.'/c/c/foo/ClassMapBaz.php',
@ -894,10 +894,10 @@ EOF;
], ],
include $this->vendorDir.'/composer/autoload_classmap.php' 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')); self::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->setApcuPrefix(', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
} }
public function testClassMapAutoloadingAuthoritativeAndApcuPrefix(): void public function testClassMapAutoloadingAuthoritativeAndApcuPrefix(): void
@ -933,8 +933,8 @@ EOF;
$this->generator->setApcu(true, 'custom\'Prefix'); $this->generator->setApcu(true, 'custom\'Prefix');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); $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."); self::assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$this->assertEquals( self::assertEquals(
[ [
'ClassMapBar' => $this->vendorDir.'/b/b/ClassMapBar.php', 'ClassMapBar' => $this->vendorDir.'/b/b/ClassMapBar.php',
'ClassMapBaz' => $this->vendorDir.'/c/c/foo/ClassMapBaz.php', 'ClassMapBaz' => $this->vendorDir.'/c/c/foo/ClassMapBaz.php',
@ -943,10 +943,10 @@ EOF;
], ],
include $this->vendorDir.'/composer/autoload_classmap.php' 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')); self::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->setApcuPrefix(\'custom\\\'Prefix\');', (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
} }
public function testFilesAutoloadGeneration(): void public function testFilesAutoloadGeneration(): void
@ -982,18 +982,18 @@ EOF;
file_put_contents($this->workingDir.'/root.php', '<?php function testFilesAutoloadGenerationRoot() {}'); file_put_contents($this->workingDir.'/root.php', '<?php function testFilesAutoloadGenerationRoot() {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoload'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoload');
$this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); self::assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php');
$this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions.php', $this->vendorDir.'/composer/autoload_real.php'); self::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'); self::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_files_functions.php', $this->vendorDir.'/composer/autoload_files.php');
$loader = require $this->vendorDir . '/autoload.php'; $loader = require $this->vendorDir . '/autoload.php';
$loader->unregister(); $loader->unregister();
$this->assertTrue(function_exists('testFilesAutoloadGeneration1')); self::assertTrue(function_exists('testFilesAutoloadGeneration1'));
$this->assertTrue(function_exists('testFilesAutoloadGeneration2')); self::assertTrue(function_exists('testFilesAutoloadGeneration2'));
$this->assertTrue(function_exists('testFilesAutoloadGeneration3')); self::assertTrue(function_exists('testFilesAutoloadGeneration3'));
$this->assertTrue(function_exists('testFilesAutoloadGeneration4')); self::assertTrue(function_exists('testFilesAutoloadGeneration4'));
$this->assertTrue(function_exists('testFilesAutoloadGenerationRoot')); self::assertTrue(function_exists('testFilesAutoloadGenerationRoot'));
} }
public function testFilesAutoloadGenerationRemoveExtraEntitiesFromAutoloadFiles(): void public function testFilesAutoloadGenerationRemoveExtraEntitiesFromAutoloadFiles(): void
@ -1047,24 +1047,24 @@ EOF;
file_put_contents($this->workingDir.'/root.php', '<?php function testFilesAutoloadGenerationRoot() {}'); file_put_contents($this->workingDir.'/root.php', '<?php function testFilesAutoloadGenerationRoot() {}');
$this->generator->dump($this->config, $this->repository, $autoloadPackage, $this->im, 'composer', false, 'FilesAutoload'); $this->generator->dump($this->config, $this->repository, $autoloadPackage, $this->im, 'composer', false, 'FilesAutoload');
$this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); self::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'); self::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'); self::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'); self::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/include_paths_functions.php', $this->vendorDir.'/composer/include_paths.php');
$this->generator->dump($this->config, $this->repository, $autoloadPackage, $this->im, 'composer', false, 'FilesAutoload'); $this->generator->dump($this->config, $this->repository, $autoloadPackage, $this->im, 'composer', false, 'FilesAutoload');
$this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); self::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'); self::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'); self::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/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->generator->dump($this->config, $this->repository, $notAutoloadPackage, $this->im, 'composer', false, 'FilesAutoload');
$this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); self::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'); self::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'); self::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'); self::assertFileDoesNotExist($this->vendorDir.'/composer/autoload_files.php');
$this->assertFileDoesNotExist($this->vendorDir.'/composer/include_paths.php'); self::assertFileDoesNotExist($this->vendorDir.'/composer/include_paths.php');
} }
public function testFilesAutoloadOrderByDependencies(): void public function testFilesAutoloadOrderByDependencies(): void
@ -1124,19 +1124,19 @@ EOF;
file_put_contents($this->workingDir . '/root2.php', '<?php function testFilesAutoloadOrderByDependencyRoot() {}'); file_put_contents($this->workingDir . '/root2.php', '<?php function testFilesAutoloadOrderByDependencyRoot() {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoloadOrder'); $this->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'); self::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'); self::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_static_files_by_dependency.php', $this->vendorDir . '/composer/autoload_static.php');
$loader = require $this->vendorDir . '/autoload.php'; $loader = require $this->vendorDir . '/autoload.php';
$loader->unregister(); $loader->unregister();
$this->assertTrue(function_exists('testFilesAutoloadOrderByDependency1')); self::assertTrue(function_exists('testFilesAutoloadOrderByDependency1'));
$this->assertTrue(function_exists('testFilesAutoloadOrderByDependency2')); self::assertTrue(function_exists('testFilesAutoloadOrderByDependency2'));
$this->assertTrue(function_exists('testFilesAutoloadOrderByDependency3')); self::assertTrue(function_exists('testFilesAutoloadOrderByDependency3'));
$this->assertTrue(function_exists('testFilesAutoloadOrderByDependency4')); self::assertTrue(function_exists('testFilesAutoloadOrderByDependency4'));
$this->assertTrue(function_exists('testFilesAutoloadOrderByDependency5')); self::assertTrue(function_exists('testFilesAutoloadOrderByDependency5'));
$this->assertTrue(function_exists('testFilesAutoloadOrderByDependencyRoot')); self::assertTrue(function_exists('testFilesAutoloadOrderByDependencyRoot'));
} }
/** /**
@ -1235,9 +1235,9 @@ return array(
EOF; EOF;
$this->generator->dump($this->config, $this->repository, $rootPackage, $this->im, 'composer', true, '_9'); $this->generator->dump($this->config, $this->repository, $rootPackage, $this->im, 'composer', true, '_9');
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap);
} }
public function testIncludePathFileGeneration(): void public function testIncludePathFileGeneration(): void
@ -1266,8 +1266,8 @@ EOF;
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_10'); $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'); self::assertFileContentEquals(__DIR__.'/Fixtures/include_paths.php', $this->vendorDir.'/composer/include_paths.php');
$this->assertEquals( self::assertEquals(
[ [
$this->vendorDir."/a/a/lib", $this->vendorDir."/a/a/lib",
$this->vendorDir."/b/b/library", $this->vendorDir."/b/b/library",
@ -1300,7 +1300,7 @@ EOF;
$loader = require $this->vendorDir."/autoload.php"; $loader = require $this->vendorDir."/autoload.php";
$loader->unregister(); $loader->unregister();
$this->assertEquals( self::assertEquals(
$this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath, $this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath,
get_include_path() get_include_path()
); );
@ -1329,7 +1329,7 @@ EOF;
$loader = require $this->vendorDir."/autoload.php"; $loader = require $this->vendorDir."/autoload.php";
$loader->unregister(); $loader->unregister();
$this->assertEquals( self::assertEquals(
$this->workingDir."/lib".PATH_SEPARATOR.$this->workingDir."/src".PATH_SEPARATOR.$this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath, $this->workingDir."/lib".PATH_SEPARATOR.$this->workingDir."/src".PATH_SEPARATOR.$this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath,
get_include_path() get_include_path()
); );
@ -1353,7 +1353,7 @@ EOF;
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_12'); $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 public function testPreAndPostEventsAreDispatchedDuringAutoloadDump(): void
@ -1367,7 +1367,7 @@ EOF;
[ScriptEvents::POST_AUTOLOAD_DUMP, false] [ScriptEvents::POST_AUTOLOAD_DUMP, false]
]; ];
$this->assertSame(array_shift($series), [$type, $dev]); self::assertSame(array_shift($series), [$type, $dev]);
return 0; return 0;
}); });
@ -1400,8 +1400,8 @@ EOF;
$this->fs->ensureDirectoryExists($this->vendorDir.'/a'); $this->fs->ensureDirectoryExists($this->vendorDir.'/a');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'IncludePath'); $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'); self::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_static_include_path.php', $this->vendorDir.'/composer/autoload_static.php');
} }
public function testVendorDirExcludedFromWorkingDir(): void public function testVendorDirExcludedFromWorkingDir(): void
@ -1511,11 +1511,11 @@ return array(
EOF; EOF;
$this->assertStringEqualsFile($vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); self::assertStringEqualsFile($vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
$this->assertStringEqualsFile($vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); self::assertStringEqualsFile($vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
$this->assertStringEqualsFile($vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); self::assertStringEqualsFile($vendorDir.'/composer/autoload_classmap.php', $expectedClassmap);
$this->assertStringContainsString("\$vendorDir . '/b/b/bootstrap.php',\n", (string) file_get_contents($vendorDir.'/composer/autoload_files.php')); self::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::assertStringContainsString("\$baseDir . '/test.php',\n", (string) file_get_contents($vendorDir.'/composer/autoload_files.php'));
} }
public function testUpLevelRelativePaths(): void public function testUpLevelRelativePaths(): void
@ -1596,10 +1596,10 @@ return array(
EOF; EOF;
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); self::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::assertStringContainsString("\$baseDir . '/../test.php',\n", (string) file_get_contents($this->vendorDir.'/composer/autoload_files.php'));
} }
public function testAutoloadRulesInPackageThatDoesNotExistOnDisk(): void public function testAutoloadRulesInPackageThatDoesNotExistOnDisk(): void
@ -1632,7 +1632,7 @@ return array(
); );
EOF; EOF;
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
$dep->setAutoload([ $dep->setAutoload([
'psr-4' => ['Acme\Foo\\' => './src-psr4'], 'psr-4' => ['Acme\Foo\\' => './src-psr4'],
@ -1652,7 +1652,7 @@ return array(
); );
EOF; EOF;
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
$dep->setAutoload([ $dep->setAutoload([
'classmap' => ['classmap'], 'classmap' => ['classmap'],
@ -1660,14 +1660,14 @@ EOF;
try { try {
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_19'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_19');
} catch (\RuntimeException $e) { } 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([ $dep->setAutoload([
'files' => ['./test.php'], 'files' => ['./test.php'],
]); ]);
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_19'); $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([ $package->setAutoload([
'exclude-from-classmap' => ['../excludedroot', 'root/excl'], 'exclude-from-classmap' => ['../excludedroot', 'root/excl'],
@ -1677,7 +1677,7 @@ EOF;
]); ]);
$map = $this->generator->buildPackageMap($this->im, $package, [$dep]); $map = $this->generator->buildPackageMap($this->im, $package, [$dep]);
$parsed = $this->generator->parseAutoloads($map, $package); $parsed = $this->generator->parseAutoloads($map, $package);
$this->assertSame([ self::assertSame([
preg_quote(strtr((string) realpath(dirname($this->workingDir)), '\\', '/')).'/excludedroot($|/)', preg_quote(strtr((string) realpath(dirname($this->workingDir)), '\\', '/')).'/excludedroot($|/)',
preg_quote(strtr((string) realpath($this->workingDir), '\\', '/')).'/root/excl($|/)', preg_quote(strtr((string) realpath($this->workingDir), '\\', '/')).'/root/excl($|/)',
], $parsed['exclude-from-classmap']); ], $parsed['exclude-from-classmap']);
@ -1746,9 +1746,9 @@ return array(
EOF; EOF;
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap);
} }
public function testVendorSubstringPath(): void public function testVendorSubstringPath(): void
@ -1794,8 +1794,8 @@ return array(
EOF; EOF;
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'VendorSubstring'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'VendorSubstring');
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4); self::assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
} }
public function testExcludeFromClassmap(): void public function testExcludeFromClassmap(): void
@ -1864,7 +1864,7 @@ EOF;
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
// Assert that autoload_classmap.php was correctly generated. // 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'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
if (null === $expectedFixture) { if (null === $expectedFixture) {
$this->assertFileDoesNotExist($this->vendorDir . '/composer/platform_check.php'); self::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::assertStringNotContainsString("require __DIR__ . '/platform_check.php';", (string) file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
} else { } else {
$this->assertFileContentEquals(__DIR__ . '/Fixtures/platform/' . $expectedFixture . '.php', $this->vendorDir . '/composer/platform_check.php'); self::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::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'; $a = __DIR__.'/Fixtures/autoload_'.$name.'.php';
$b = $dir.'/autoload_'.$type.'.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 public static function assertFileContentEquals(string $expected, string $actual, ?string $message = null): void

View File

@ -34,7 +34,7 @@ class ClassLoaderTest extends TestCase
$loader->add('Pearlike_', __DIR__ . '/Fixtures'); $loader->add('Pearlike_', __DIR__ . '/Fixtures');
$loader->addPsr4('ShinyVendor\\ShinyPackage\\', __DIR__ . '/Fixtures'); $loader->addPsr4('ShinyVendor\\ShinyPackage\\', __DIR__ . '/Fixtures');
$loader->loadClass($class); $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 public function testGetPrefixesWithNoPSR0Configuration(): void
{ {
$loader = new ClassLoader(); $loader = new ClassLoader();
$this->assertEmpty($loader->getPrefixes()); self::assertEmpty($loader->getPrefixes());
} }
public function testSerializability(): void public function testSerializability(): void

View File

@ -77,9 +77,9 @@ class CacheTest extends TestCase
$this->cache->gc(600, 1024 * 1024 * 1024); $this->cache->gc(600, 1024 * 1024 * 1024);
for ($i = 1; $i < 4; $i++) { 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 public function testRemoveFilesWhenCacheIsTooLarge(): void
@ -106,15 +106,15 @@ class CacheTest extends TestCase
$this->cache->gc(600, 1500); $this->cache->gc(600, 1500);
for ($i = 0; $i < 3; $i++) { 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 public function testClearCache(): void
{ {
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$cache = new Cache($io, $this->root, 'a-z0-9.', $this->filesystem); $cache = new Cache($io, $this->root, 'a-z0-9.', $this->filesystem);
$this->assertTrue($cache->clear()); self::assertTrue($cache->clear());
} }
} }

View File

@ -12,10 +12,10 @@ class AboutCommandTest extends TestCase
{ {
$composerVersion = Composer::getVersion(); $composerVersion = Composer::getVersion();
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$this->assertSame(0, $appTester->run(['command' => 'about'])); self::assertSame(0, $appTester->run(['command' => 'about']));
$this->assertStringContainsString("Composer - Dependency Manager for PHP - version $composerVersion", $appTester->getDisplay()); 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()); self::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("See https://getcomposer.org/ for more information.", $appTester->getDisplay());
} }
} }

View File

@ -103,7 +103,7 @@ class ArchiveCommandTest extends TestCase
null null
)->willReturn(0); )->willReturn(0);
$this->assertEquals(0, $command->run($input, $output)); self::assertEquals(0, $command->run($input, $output));
} }
public function testUsesConfigFromComposerObjectWithPackageName(): void public function testUsesConfigFromComposerObjectWithPackageName(): void

View File

@ -45,7 +45,7 @@ class BaseDependencyCommandTest extends TestCase
$this->expectExceptionMessage($expectedExceptionMessage); $this->expectExceptionMessage($expectedExceptionMessage);
$appTester = $this->getApplicationTester(); $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'); $this->expectExceptionMessage('A valid composer.lock file is required to run this command with --locked');
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$this->assertEquals( self::assertEquals(
Command::FAILURE, Command::FAILURE,
$appTester->run(['command' => $command] + $parameters + ['--locked' => true] $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)); $this->expectExceptionMessage(sprintf('Could not find package "%s" in your project', $packageToBeInspected));
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$this->assertEquals( self::assertEquals(
Command::FAILURE, Command::FAILURE,
$appTester->run(['command' => $command] + $parameters) $appTester->run(['command' => $command] + $parameters)
); );
@ -164,7 +164,7 @@ class BaseDependencyCommandTest extends TestCase
$appTester = $this->getApplicationTester(); $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 = $this->getApplicationTester();
$appTester->run(['command' => $command] + $parameters); $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()); 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()); self::assertSame($expectedStatusCode, $appTester->getStatusCode());
$this->assertSame(trim($expectedOutput), $this->trimLines($appTester->getDisplay(true))); self::assertSame(trim($expectedOutput), $this->trimLines($appTester->getDisplay(true)));
} }
/** /**

View File

@ -41,10 +41,10 @@ class BumpCommandTest extends TestCase
} }
$appTester = $this->getApplicationTester(); $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'); $json = new JsonFile('./composer.json');
$this->assertSame($expected, $json->read()); self::assertSame($expected, $json->read());
} }
public function testBumpFailsOnNonExistingComposerFile(): void public function testBumpFailsOnNonExistingComposerFile(): void
@ -54,9 +54,9 @@ class BumpCommandTest extends TestCase
unlink($composerJsonPath); unlink($composerJsonPath);
$appTester = $this->getApplicationTester(); $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 public function testBumpFailsOnWriteErrorToComposerFile(): void
@ -66,9 +66,9 @@ class BumpCommandTest extends TestCase
chmod($composerJsonPath, 0444); chmod($composerJsonPath, 0444);
$appTester = $this->getApplicationTester(); $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 public static function provideTests(): \Generator

View File

@ -47,7 +47,7 @@ class CheckPlatformReqsCommandTest extends TestCase
$appTester->run(array_merge(['command' => 'check-platform-reqs'], $command)); $appTester->run(array_merge(['command' => 'check-platform-reqs'], $command));
$appTester->assertCommandIsSuccessful(); $appTester->assertCommandIsSuccessful();
$this->assertSame(trim($expected), trim($appTester->getDisplay(true))); self::assertSame(trim($expected), trim($appTester->getDisplay(true)));
} }
public function testExceptionThrownIfNoLockfileFound(): void public function testExceptionThrownIfNoLockfileFound(): void
@ -89,7 +89,7 @@ ext-foobar 2.3.4 success'
]; ];
} }
public function testFailedPlatformRequirement(): void public function testFailedPlatformRequirement(): void
{ {
$this->initTempComposer([ $this->initTempComposer([
'require' => [ '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)));
} }
} }

View File

@ -32,7 +32,7 @@ class ClearCacheCommandTest extends TestCase
$output = $appTester->getDisplay(true); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('All caches cleared.', $output); self::assertStringContainsString('All caches cleared.', $output);
} }
public function testClearCacheCommandWithOptionGarbageCollection(): void public function testClearCacheCommandWithOptionGarbageCollection(): void
@ -44,7 +44,7 @@ class ClearCacheCommandTest extends TestCase
$output = $appTester->getDisplay(true); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('All caches garbage-collected.', $output); self::assertStringContainsString('All caches garbage-collected.', $output);
} }
public function testClearCacheCommandWithOptionNoCache(): void public function testClearCacheCommandWithOptionNoCache(): void
@ -56,6 +56,6 @@ class ClearCacheCommandTest extends TestCase
$output = $appTester->getDisplay(true); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('Cache is not enabled', $output); self::assertStringContainsString('Cache is not enabled', $output);
} }
} }

View File

@ -32,7 +32,7 @@ class ConfigCommandTest extends TestCase
$appTester->assertCommandIsSuccessful($appTester->getDisplay()); $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 public static function provideConfigUpdates(): \Generator
@ -133,8 +133,8 @@ class ConfigCommandTest extends TestCase
$appTester->assertCommandIsSuccessful(); $appTester->assertCommandIsSuccessful();
$this->assertSame($expected, trim($appTester->getDisplay(true))); self::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($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 public static function provideConfigReads(): \Generator

View File

@ -23,13 +23,13 @@ class DiagnoseCommandTest extends TestCase
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(['command' => 'diagnose']); $appTester->run(['command' => 'diagnose']);
$this->assertSame(1, $appTester->getStatusCode()); self::assertSame(1, $appTester->getStatusCode());
$output = $appTester->getDisplay(true); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('Checking composer.json: <warning>WARNING</warning> self::assertStringContainsString('Checking composer.json: <warning>WARNING</warning>
<warning>No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.</warning>', $output); <warning>No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.</warning>', $output);
$this->assertStringContainsString('Checking http connectivity to packagist: OK self::assertStringContainsString('Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK Checking https connectivity to packagist: OK
Checking github.com rate limit: ', $output); Checking github.com rate limit: ', $output);
} }
@ -44,9 +44,9 @@ Checking github.com rate limit: ', $output);
$appTester->assertCommandIsSuccessful(); $appTester->assertCommandIsSuccessful();
$output = $appTester->getDisplay(true); $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 https connectivity to packagist: OK
Checking github.com rate limit: ', $output); Checking github.com rate limit: ', $output);
} }

View File

@ -10,41 +10,41 @@ class DumpAutoloadCommandTest extends TestCase
public function testDumpAutoload(): void public function testDumpAutoload(): void
{ {
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$this->assertSame(0, $appTester->run(['command' => 'dump-autoload'])); self::assertSame(0, $appTester->run(['command' => 'dump-autoload']));
$output = $appTester->getDisplay(true); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('Generating autoload files', $output); self::assertStringContainsString('Generating autoload files', $output);
$this->assertStringContainsString('Generated autoload files', $output); self::assertStringContainsString('Generated autoload files', $output);
} }
public function testDumpDevAutoload(): void public function testDumpDevAutoload(): void
{ {
$appTester = $this->getApplicationTester(); $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); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('Generating autoload files', $output); self::assertStringContainsString('Generating autoload files', $output);
$this->assertStringContainsString('Generated autoload files', $output); self::assertStringContainsString('Generated autoload files', $output);
} }
public function testDumpNoDevAutoload(): void public function testDumpNoDevAutoload(): void
{ {
$appTester = $this->getApplicationTester(); $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); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('Generating autoload files', $output); self::assertStringContainsString('Generating autoload files', $output);
$this->assertStringContainsString('Generated autoload files', $output); self::assertStringContainsString('Generated autoload files', $output);
} }
public function testUsingOptimizeAndStrictPsr(): void public function testUsingOptimizeAndStrictPsr(): void
{ {
$appTester = $this->getApplicationTester(); $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); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('Generating optimized autoload files', $output); self::assertStringContainsString('Generating optimized autoload files', $output);
$this->assertMatchesRegularExpression('/Generated optimized autoload files containing \d+ classes/', $output); self::assertMatchesRegularExpression('/Generated optimized autoload files containing \d+ classes/', $output);
} }
public function testFailsUsingStrictPsrIfClassMapViolationsAreFound(): void public function testFailsUsingStrictPsrIfClassMapViolationsAreFound(): void
@ -59,30 +59,30 @@ class DumpAutoloadCommandTest extends TestCase
mkdir($dir . '/src/'); mkdir($dir . '/src/');
file_put_contents($dir . '/src/Foo.php', '<?php namespace Application\Src; class Foo {}'); file_put_contents($dir . '/src/Foo.php', '<?php namespace Application\Src; class Foo {}');
$appTester = $this->getApplicationTester(); $appTester = $this->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); $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 public function testUsingClassmapAuthoritative(): void
{ {
$appTester = $this->getApplicationTester(); $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); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('Generating optimized autoload files (authoritative)', $output); self::assertStringContainsString('Generating optimized autoload files (authoritative)', $output);
$this->assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output); self::assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output);
} }
public function testUsingClassmapAuthoritativeAndStrictPsr(): void public function testUsingClassmapAuthoritativeAndStrictPsr(): void
{ {
$appTester = $this->getApplicationTester(); $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); $output = $appTester->getDisplay(true);
$this->assertStringContainsString('Generating optimized autoload files', $output); self::assertStringContainsString('Generating optimized autoload files', $output);
$this->assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output); self::assertMatchesRegularExpression('/Generated optimized autoload files \(authoritative\) containing \d+ classes/', $output);
} }
public function testStrictPsrDoesNotWorkWithoutOptimizedAutoloader(): void public function testStrictPsrDoesNotWorkWithoutOptimizedAutoloader(): void
@ -112,7 +112,7 @@ class DumpAutoloadCommandTest extends TestCase
]); ]);
$appTester = $this->getApplicationTester(); $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')); self::assertStringContainsString('ComposerAutoloaderInitFoobar', (string) file_get_contents($dir . '/vendor/autoload.php'));
} }
@ -147,7 +147,7 @@ class DumpAutoloadCommandTest extends TestCase
); );
$appTester = $this->getApplicationTester(); $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')); self::assertStringContainsString('ComposerAutoloaderInitFoobar', (string) file_get_contents($dir . '/vendor/autoload.php'));
} }
@ -180,7 +180,7 @@ class DumpAutoloadCommandTest extends TestCase
); );
$appTester = $this->getApplicationTester(); $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')); self::assertStringContainsString('ComposerAutoloaderInit2d4a6be9a93712c5d6a119b26734a047', (string) file_get_contents($dir . '/vendor/autoload.php'));
} }

View File

@ -49,7 +49,7 @@ class ExecCommandTest extends TestCase
$output = $appTester->getDisplay(true); $output = $appTester->getDisplay(true);
$this->assertSame( self::assertSame(
'Available binaries: 'Available binaries:
- b - b
- c - c

View File

@ -56,7 +56,7 @@ class FundCommandTest extends TestCase
$appTester->run(array_merge(['command' => 'fund'], $command)); $appTester->run(array_merge(['command' => 'fund'], $command));
$appTester->assertCommandIsSuccessful(); $appTester->assertCommandIsSuccessful();
$this->assertSame(trim($expected), trim($appTester->getDisplay(true))); self::assertSame(trim($expected), trim($appTester->getDisplay(true)));
} }
public static function useCaseProvider(): Generator public static function useCaseProvider(): Generator

View File

@ -54,7 +54,7 @@ class HomeCommandTest extends TestCase
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(array_merge(['command' => 'home', '--show' => true], $command)); $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 public static function useCaseProvider(): Generator

View File

@ -23,24 +23,24 @@ class InitCommandTest extends TestCase
{ {
$command = new InitCommand; $command = new InitCommand;
$author = $this->callParseAuthorString($command, 'John Smith <john@example.com>'); $author = $this->callParseAuthorString($command, 'John Smith <john@example.com>');
$this->assertEquals('John Smith', $author['name']); self::assertEquals('John Smith', $author['name']);
$this->assertEquals('john@example.com', $author['email']); self::assertEquals('john@example.com', $author['email']);
} }
public function testParseValidAuthorStringWithoutEmail(): void public function testParseValidAuthorStringWithoutEmail(): void
{ {
$command = new InitCommand; $command = new InitCommand;
$author = $this->callParseAuthorString($command, 'John Smith'); $author = $this->callParseAuthorString($command, 'John Smith');
$this->assertEquals('John Smith', $author['name']); self::assertEquals('John Smith', $author['name']);
$this->assertNull($author['email']); self::assertNull($author['email']);
} }
public function testParseValidUtf8AuthorString(): void public function testParseValidUtf8AuthorString(): void
{ {
$command = new InitCommand; $command = new InitCommand;
$author = $this->callParseAuthorString($command, 'Matti Meikäläinen <matti@example.com>'); $author = $this->callParseAuthorString($command, 'Matti Meikäläinen <matti@example.com>');
$this->assertEquals('Matti Meikäläinen', $author['name']); self::assertEquals('Matti Meikäläinen', $author['name']);
$this->assertEquals('matti@example.com', $author['email']); self::assertEquals('matti@example.com', $author['email']);
} }
public function testParseValidUtf8AuthorStringWithNonSpacingMarks(): void public function testParseValidUtf8AuthorStringWithNonSpacingMarks(): void
@ -49,16 +49,16 @@ class InitCommandTest extends TestCase
$utf8_expected = "Matti Meika\xCC\x88la\xCC\x88inen"; $utf8_expected = "Matti Meika\xCC\x88la\xCC\x88inen";
$command = new InitCommand; $command = new InitCommand;
$author = $this->callParseAuthorString($command, $utf8_expected." <matti@example.com>"); $author = $this->callParseAuthorString($command, $utf8_expected." <matti@example.com>");
$this->assertEquals($utf8_expected, $author['name']); self::assertEquals($utf8_expected, $author['name']);
$this->assertEquals('matti@example.com', $author['email']); self::assertEquals('matti@example.com', $author['email']);
} }
public function testParseNumericAuthorString(): void public function testParseNumericAuthorString(): void
{ {
$command = new InitCommand; $command = new InitCommand;
$author = $this->callParseAuthorString($command, 'h4x0r <h4x@example.com>'); $author = $this->callParseAuthorString($command, 'h4x0r <h4x@example.com>');
$this->assertEquals('h4x0r', $author['name']); self::assertEquals('h4x0r', $author['name']);
$this->assertEquals('h4x@example.com', $author['email']); self::assertEquals('h4x@example.com', $author['email']);
} }
/** /**
@ -72,8 +72,8 @@ class InitCommandTest extends TestCase
$command, $command,
'Johnathon "Johnny" Smith <john@example.com>' 'Johnathon "Johnny" Smith <john@example.com>'
); );
$this->assertEquals('Johnathon "Johnny" Smith', $author['name']); self::assertEquals('Johnathon "Johnny" Smith', $author['name']);
$this->assertEquals('john@example.com', $author['email']); self::assertEquals('john@example.com', $author['email']);
} }
/** /**
@ -87,8 +87,8 @@ class InitCommandTest extends TestCase
$command, $command,
'Johnathon (Johnny) Smith <john@example.com>' 'Johnathon (Johnny) Smith <john@example.com>'
); );
$this->assertEquals('Johnathon (Johnny) Smith', $author['name']); self::assertEquals('Johnathon (Johnny) Smith', $author['name']);
$this->assertEquals('john@example.com', $author['email']); self::assertEquals('john@example.com', $author['email']);
} }
public function testParseEmptyAuthorString(): void public function testParseEmptyAuthorString(): void
@ -109,21 +109,21 @@ class InitCommandTest extends TestCase
{ {
$command = new InitCommand; $command = new InitCommand;
$namespace = $command->namespaceFromPackageName('new_projects.acme-extra/package-name'); $namespace = $command->namespaceFromPackageName('new_projects.acme-extra/package-name');
$this->assertEquals('NewProjectsAcmeExtra\PackageName', $namespace); self::assertEquals('NewProjectsAcmeExtra\PackageName', $namespace);
} }
public function testNamespaceFromInvalidPackageName(): void public function testNamespaceFromInvalidPackageName(): void
{ {
$command = new InitCommand; $command = new InitCommand;
$namespace = $command->namespaceFromPackageName('invalid-package-name'); $namespace = $command->namespaceFromPackageName('invalid-package-name');
$this->assertNull($namespace); self::assertNull($namespace);
} }
public function testNamespaceFromMissingPackageName(): void public function testNamespaceFromMissingPackageName(): void
{ {
$command = new InitCommand; $command = new InitCommand;
$namespace = $command->namespaceFromPackageName(''); $namespace = $command->namespaceFromPackageName('');
$this->assertNull($namespace); self::assertNull($namespace);
} }
/** /**
@ -168,7 +168,7 @@ class InitCommandTest extends TestCase
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(['command' => 'init', '--no-interaction' => true, '--name' => 'test/pkg']); $appTester->run(['command' => 'init', '--no-interaction' => true, '--name' => 'test/pkg']);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -176,7 +176,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunInvalidAuthorArgumentInvalidEmail(): void public function testRunInvalidAuthorArgumentInvalidEmail(): void
@ -210,7 +210,7 @@ class InitCommandTest extends TestCase
'--author' => 'Mr. Test <test@example.org>', '--author' => 'Mr. Test <test@example.org>',
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -224,7 +224,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunAuthorArgumentMissingEmail(): void public function testRunAuthorArgumentMissingEmail(): void
@ -241,7 +241,7 @@ class InitCommandTest extends TestCase
'--author' => 'Mr. Test', '--author' => 'Mr. Test',
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -254,7 +254,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunSingleRepositoryArgument(): void public function testRunSingleRepositoryArgument(): void
@ -273,7 +273,7 @@ class InitCommandTest extends TestCase
], ],
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -287,7 +287,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunMultipleRepositoryArguments(): void public function testRunMultipleRepositoryArguments(): void
@ -308,7 +308,7 @@ class InitCommandTest extends TestCase
], ],
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -335,7 +335,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunStability(): void public function testRunStability(): void
@ -352,7 +352,7 @@ class InitCommandTest extends TestCase
'--stability' => 'dev', '--stability' => 'dev',
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -361,7 +361,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunInvalidStability(): void public function testRunInvalidStability(): void
@ -378,9 +378,9 @@ class InitCommandTest extends TestCase
'--stability' => 'bogus', '--stability' => 'bogus',
], ['capture_stderr_separately' => true]); ], ['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 public function testRunRequireOne(): void
@ -399,7 +399,7 @@ class InitCommandTest extends TestCase
], ],
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -409,7 +409,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunRequireMultiple(): void public function testRunRequireMultiple(): void
@ -429,7 +429,7 @@ class InitCommandTest extends TestCase
], ],
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -440,7 +440,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunInvalidRequire(): void public function testRunInvalidRequire(): void
@ -479,7 +479,7 @@ class InitCommandTest extends TestCase
], ],
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -490,7 +490,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunRequireDevMultiple(): void public function testRunRequireDevMultiple(): void
@ -510,7 +510,7 @@ class InitCommandTest extends TestCase
], ],
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -522,7 +522,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunInvalidRequireDev(): void public function testRunInvalidRequireDev(): void
@ -559,7 +559,7 @@ class InitCommandTest extends TestCase
'--autoload' => 'testMapping/' '--autoload' => 'testMapping/'
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -572,7 +572,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunHomepage(): void public function testRunHomepage(): void
@ -589,7 +589,7 @@ class InitCommandTest extends TestCase
'--homepage' => 'https://example.org/' '--homepage' => 'https://example.org/'
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -598,7 +598,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunInvalidHomepage(): void public function testRunInvalidHomepage(): void
@ -615,8 +615,8 @@ class InitCommandTest extends TestCase
'--homepage' => 'not-a-url', '--homepage' => 'not-a-url',
], ['capture_stderr_separately' => true]); ], ['capture_stderr_separately' => true]);
$this->assertSame(1, $appTester->getStatusCode()); self::assertSame(1, $appTester->getStatusCode());
$this->assertMatchesRegularExpression("/homepage\s*:\s*Invalid URL format/", $appTester->getErrorOutput()); self::assertMatchesRegularExpression("/homepage\s*:\s*Invalid URL format/", $appTester->getErrorOutput());
} }
public function testRunDescription(): void public function testRunDescription(): void
@ -633,7 +633,7 @@ class InitCommandTest extends TestCase
'--description' => 'My first example package' '--description' => 'My first example package'
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -642,7 +642,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunType(): void public function testRunType(): void
@ -659,7 +659,7 @@ class InitCommandTest extends TestCase
'--type' => 'library' '--type' => 'library'
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -668,7 +668,7 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
public function testRunLicense(): void public function testRunLicense(): void
@ -685,7 +685,7 @@ class InitCommandTest extends TestCase
'--license' => 'MIT' '--license' => 'MIT'
]); ]);
$this->assertSame(0, $appTester->getStatusCode()); self::assertSame(0, $appTester->getStatusCode());
$expected = [ $expected = [
'name' => 'test/pkg', 'name' => 'test/pkg',
@ -694,6 +694,6 @@ class InitCommandTest extends TestCase
]; ];
$file = new JsonFile($dir . '/composer.json'); $file = new JsonFile($dir . '/composer.json');
$this->assertEquals($expected, $file->read()); self::assertEquals($expected, $file->read());
} }
} }

View File

@ -42,7 +42,7 @@ class InstallCommandTest extends TestCase
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(array_merge(['command' => 'install'], $command)); $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 public function errorCaseProvider(): Generator
@ -118,7 +118,7 @@ OUTPUT
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(['command' => 'install', '--no-progress' => true]); $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. Verifying lock file contents can be installed on current platform.
Package operations: 2 installs, 0 updates, 0 removals Package operations: 2 installs, 0 updates, 0 removals
- Installing root/another (1.0.0) - Installing root/another (1.0.0)
@ -148,7 +148,7 @@ Generating autoload files', trim($appTester->getDisplay(true)));
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(['command' => 'install', '--no-progress' => true, '--no-dev' => true]); $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. Verifying lock file contents can be installed on current platform.
Package operations: 1 install, 0 updates, 0 removals Package operations: 1 install, 0 updates, 0 removals
- Installing root/req (1.0.0) - Installing root/req (1.0.0)
@ -175,7 +175,7 @@ Generating autoload files', trim($appTester->getDisplay(true)));
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(['command' => 'install', '--no-progress' => true]); $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. Verifying lock file contents can be installed on current platform.
Package operations: 1 install, 0 updates, 0 removals Package operations: 1 install, 0 updates, 0 removals
- Installing root/another (1.0.0) - Installing root/another (1.0.0)

View File

@ -54,7 +54,7 @@ class LicensesCommandTest extends TestCase
public function testBasicRun(): void public function testBasicRun(): void
{ {
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$this->assertSame(0, $appTester->run(['command' => 'license'])); self::assertSame(0, $appTester->run(['command' => 'license']));
$expected = [ $expected = [
["Name:", "test/pkg"], ["Name:", "test/pkg"],
@ -81,14 +81,14 @@ class LicensesCommandTest extends TestCase
if (!isset($expected[$i])) { if (!isset($expected[$i])) {
$this->fail('Got more output lines than expected'); $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 public function testNoDev(): void
{ {
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$this->assertSame(0, $appTester->run(['command' => 'license', '--no-dev' => true])); self::assertSame(0, $appTester->run(['command' => 'license', '--no-dev' => true]));
$expected = [ $expected = [
["Name:", "test/pkg"], ["Name:", "test/pkg"],
@ -114,14 +114,14 @@ class LicensesCommandTest extends TestCase
if (!isset($expected[$i])) { if (!isset($expected[$i])) {
$this->fail('Got more output lines than expected'); $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 public function testFormatJson(): void
{ {
$appTester = $this->getApplicationTester(); $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 = [ $expected = [
"name" => "test/pkg", "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 public function testFormatSummary(): void
{ {
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$this->assertSame(0, $appTester->run(['command' => 'license', '--format' => 'summary'])); self::assertSame(0, $appTester->run(['command' => 'license', '--format' => 'summary']));
$expected = [ $expected = [
['-', '-'], ['-', '-'],
@ -176,7 +176,7 @@ class LicensesCommandTest extends TestCase
foreach ($expected as $i => $expect) { foreach ($expected as $i => $expect) {
[$key, $value] = $expect; [$key, $value] = $expect;
$this->assertMatchesRegularExpression("/$key\s+$value/", $lines[$i]); self::assertMatchesRegularExpression("/$key\s+$value/", $lines[$i]);
} }
} }

View File

@ -47,10 +47,10 @@ class ReinstallCommandTest extends TestCase
'packages' => $packages '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' => [ yield 'reinstall a package' => [
['root/req', 'root/anotherreq'], ['root/req', 'root/anotherreq'],

View File

@ -28,7 +28,7 @@ class RemoveCommandTest extends TestCase
$this->expectExceptionMessage('Not enough arguments (missing: "packages").'); $this->expectExceptionMessage('Not enough arguments (missing: "packages").');
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$this->assertEquals(Command::FAILURE, $appTester->run(['command' => 'remove'])); self::assertEquals(Command::FAILURE, $appTester->run(['command' => 'remove']));
} }
public function testExceptionWhenRunningUnusedWithoutLockFile(): void 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'); $this->expectExceptionMessage('A valid composer.lock file is required to run this command with --unused');
$appTester = $this->getApplicationTester(); $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 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::assertEquals(Command::SUCCESS, $appTester->run(['command' => 'remove', 'packages' => ['root/req'], '--dev' => true, '--no-update' => true, '--no-interaction' => true]));
self::assertSame('<warning>root/req could not be found in require-dev but it is present in require</warning> self::assertSame('<warning>root/req could not be found in require-dev but it is present in require</warning>
./composer.json has been updated', trim($appTester->getDisplay(true))); ./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 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::assertEquals(Command::SUCCESS, $appTester->run(['command' => 'remove', 'packages' => ['root/req'], '--update-with-dependencies' => true, '--no-update' => true, '--no-interaction' => true]));
self::assertSame('<warning>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.</warning> self::assertSame('<warning>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.</warning>
./composer.json has been updated', trim($appTester->getDisplay(true))); ./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 public function testMessageOutputWhenNoUnusedPackagesToRemove(): void

View File

@ -96,9 +96,9 @@ Installation failed, reverting ./composer.json to its original content.
if (str_contains($expected, '%d')) { if (str_contains($expected, '%d')) {
$pattern = '{^'.str_replace('%d', '[0-9.]+', preg_quote(trim($expected))).'$}'; $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 { } else {
$this->assertSame(trim($expected), trim($appTester->getDisplay(true))); self::assertSame(trim($expected), trim($appTester->getDisplay(true)));
} }
} }

View File

@ -105,8 +105,8 @@ class RunScriptCommandTest extends TestCase
$output = $appTester->getDisplay(); $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'); self::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('Run the codestyle fixer', $output, 'The custom description for the fix-cs script should be printed');
} }
public function testCanDefineAliases(): void public function testCanDefineAliases(): void
@ -132,7 +132,7 @@ class RunScriptCommandTest extends TestCase
$actualAliases = $array['usage']; $actualAliases = $array['usage'];
array_shift($actualAliases); 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 public function testExecutionOfCustomSymfonyCommand(): void

View File

@ -53,7 +53,7 @@ class SelfUpdateCommandTest extends TestCase
$appTester->run(['command' => 'self-update']); $appTester->run(['command' => 'self-update']);
$appTester->assertCommandIsSuccessful(); $appTester->assertCommandIsSuccessful();
$this->assertStringContainsString('Upgrading to version', $appTester->getDisplay()); self::assertStringContainsString('Upgrading to version', $appTester->getDisplay());
} }
public function testUpdateToSpecificVersion(): void public function testUpdateToSpecificVersion(): void
@ -62,7 +62,7 @@ class SelfUpdateCommandTest extends TestCase
$appTester->run(['command' => 'self-update', 'version' => '2.4.0']); $appTester->run(['command' => 'self-update', 'version' => '2.4.0']);
$appTester->assertCommandIsSuccessful(); $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 public function testUpdateWithInvalidOptionThrowsException(): void
@ -87,8 +87,8 @@ class SelfUpdateCommandTest extends TestCase
$appTester->run(['command' => 'self-update', $option => true]); $appTester->run(['command' => 'self-update', $option => true]);
$appTester->assertCommandIsSuccessful(); $appTester->assertCommandIsSuccessful();
$this->assertStringContainsString('Upgrading to version', $appTester->getDisplay()); self::assertStringContainsString('Upgrading to version', $appTester->getDisplay());
$this->assertStringContainsString($expectedOutput, $appTester->getDisplay()); self::assertStringContainsString($expectedOutput, $appTester->getDisplay());
} }
/** /**

View File

@ -30,7 +30,7 @@ class StatusCommandTest extends TestCase
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(['command' => 'status']); $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:'; $expected = 'You have changes in the following dependencies:';
$actual = trim($appTester->getDisplay(true)); $actual = trim($appTester->getDisplay(true));
$this->assertStringContainsString($expected, $actual); self::assertStringContainsString($expected, $actual);
$this->assertStringContainsString($packageData['name'], $actual); self::assertStringContainsString($packageData['name'], $actual);
} }
public static function locallyModifiedPackagesUseCaseProvider(): Generator public static function locallyModifiedPackagesUseCaseProvider(): Generator

View File

@ -29,7 +29,7 @@ class UpdateCommandTest extends TestCase
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(array_merge(['command' => 'update', '--dry-run' => true, '--no-audit' => true], $command)); $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 public static function provideUpdates(): \Generator

View File

@ -30,7 +30,7 @@ class ValidateCommandTest extends TestCase
$appTester = $this->getApplicationTester(); $appTester = $this->getApplicationTester();
$appTester->run(array_merge(['command' => 'validate'], $command)); $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 public function testValidateOnFileIssues(): void
@ -42,7 +42,7 @@ class ValidateCommandTest extends TestCase
$appTester->run(['command' => 'validate']); $appTester->run(['command' => 'validate']);
$expected = './composer.json not found.'; $expected = './composer.json not found.';
$this->assertSame($expected, trim($appTester->getDisplay(true))); self::assertSame($expected, trim($appTester->getDisplay(true)));
} }
public function testWithComposerLock(): void 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 and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require-r
OUTPUT; OUTPUT;
$this->assertSame(trim($expected), trim($appTester->getDisplay(true))); self::assertSame(trim($expected), trim($appTester->getDisplay(true)));
} }
public function testUnaccessibleFile(): void public function testUnaccessibleFile(): void
@ -79,8 +79,8 @@ OUTPUT;
$appTester->run(['command' => 'validate']); $appTester->run(['command' => 'validate']);
$expected = './composer.json is not readable.'; $expected = './composer.json is not readable.';
$this->assertSame($expected, trim($appTester->getDisplay(true))); self::assertSame($expected, trim($appTester->getDisplay(true)));
$this->assertSame(3, $appTester->getStatusCode()); self::assertSame(3, $appTester->getStatusCode());
chmod($directory.'/composer.json', 0700); chmod($directory.'/composer.json', 0700);
} }

View File

@ -136,13 +136,13 @@ class CompletionFunctionalTest extends TestCase
$suggestions = $tester->complete($input); $suggestions = $tester->complete($input);
if (null === $expectedSuggestions) { if (null === $expectedSuggestions) {
$this->assertEmpty($suggestions); self::assertEmpty($suggestions);
return; return;
} }
$diff = array_diff($expectedSuggestions, $suggestions); $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 private function getApplication(): Application

View File

@ -22,7 +22,7 @@ class ComposerTest extends TestCase
$package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
$composer->setPackage($package); $composer->setPackage($package);
$this->assertSame($package, $composer->getPackage()); self::assertSame($package, $composer->getPackage());
} }
public function testSetGetLocker(): void public function testSetGetLocker(): void
@ -31,7 +31,7 @@ class ComposerTest extends TestCase
$locker = $this->getMockBuilder('Composer\Package\Locker')->disableOriginalConstructor()->getMock(); $locker = $this->getMockBuilder('Composer\Package\Locker')->disableOriginalConstructor()->getMock();
$composer->setLocker($locker); $composer->setLocker($locker);
$this->assertSame($locker, $composer->getLocker()); self::assertSame($locker, $composer->getLocker());
} }
public function testSetGetRepositoryManager(): void public function testSetGetRepositoryManager(): void
@ -40,7 +40,7 @@ class ComposerTest extends TestCase
$manager = $this->getMockBuilder('Composer\Repository\RepositoryManager')->disableOriginalConstructor()->getMock(); $manager = $this->getMockBuilder('Composer\Repository\RepositoryManager')->disableOriginalConstructor()->getMock();
$composer->setRepositoryManager($manager); $composer->setRepositoryManager($manager);
$this->assertSame($manager, $composer->getRepositoryManager()); self::assertSame($manager, $composer->getRepositoryManager());
} }
public function testSetGetDownloadManager(): void public function testSetGetDownloadManager(): void
@ -50,7 +50,7 @@ class ComposerTest extends TestCase
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')->setConstructorArgs([$io])->getMock(); $manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')->setConstructorArgs([$io])->getMock();
$composer->setDownloadManager($manager); $composer->setDownloadManager($manager);
$this->assertSame($manager, $composer->getDownloadManager()); self::assertSame($manager, $composer->getDownloadManager());
} }
public function testSetGetInstallationManager(): void public function testSetGetInstallationManager(): void
@ -59,6 +59,6 @@ class ComposerTest extends TestCase
$manager = $this->getMockBuilder('Composer\Installer\InstallationManager')->disableOriginalConstructor()->getMock(); $manager = $this->getMockBuilder('Composer\Installer\InstallationManager')->disableOriginalConstructor()->getMock();
$composer->setInstallationManager($manager); $composer->setInstallationManager($manager);
$this->assertSame($manager, $composer->getInstallationManager()); self::assertSame($manager, $composer->getInstallationManager());
} }
} }

View File

@ -50,7 +50,7 @@ class JsonConfigSourceTest extends TestCase
$jsonConfigSource = new JsonConfigSource(new JsonFile($config)); $jsonConfigSource = new JsonConfigSource(new JsonFile($config));
$jsonConfigSource->addRepository('example_tld', ['type' => 'git', 'url' => 'example.tld']); $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 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 public function testRemoveRepository(): void
@ -78,7 +78,7 @@ class JsonConfigSourceTest extends TestCase
$jsonConfigSource = new JsonConfigSource(new JsonFile($config)); $jsonConfigSource = new JsonConfigSource(new JsonFile($config));
$jsonConfigSource->removeRepository('example_tld'); $jsonConfigSource->removeRepository('example_tld');
$this->assertFileEquals(self::fixturePath('composer-repositories.json'), $config); self::assertFileEquals(self::fixturePath('composer-repositories.json'), $config);
} }
public function testAddPackagistRepositoryWithFalseValue(): void public function testAddPackagistRepositoryWithFalseValue(): void
@ -88,7 +88,7 @@ class JsonConfigSourceTest extends TestCase
$jsonConfigSource = new JsonConfigSource(new JsonFile($config)); $jsonConfigSource = new JsonConfigSource(new JsonFile($config));
$jsonConfigSource->addRepository('packagist', false); $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 public function testRemovePackagist(): void
@ -98,7 +98,7 @@ class JsonConfigSourceTest extends TestCase
$jsonConfigSource = new JsonConfigSource(new JsonFile($config)); $jsonConfigSource = new JsonConfigSource(new JsonFile($config));
$jsonConfigSource->removeRepository('packagist'); $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); $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); $jsonConfigSource->removeLink($type, $name);
$this->assertFileEquals($compareAgainst, $composerJson); self::assertFileEquals($compareAgainst, $composerJson);
} }
/** /**

View File

@ -33,7 +33,7 @@ class ConfigTest extends TestCase
} }
$config->merge(['repositories' => $localConfig]); $config->merge(['repositories' => $localConfig]);
$this->assertEquals($expected, $config->getRepositories()); self::assertEquals($expected, $config->getRepositories());
} }
public static function dataAddPackagistRepository(): array public static function dataAddPackagistRepository(): array
@ -149,7 +149,7 @@ class ConfigTest extends TestCase
$config->merge(['config' => ['preferred-install' => 'source']]); $config->merge(['config' => ['preferred-install' => 'source']]);
$config->merge(['config' => ['preferred-install' => 'dist']]); $config->merge(['config' => ['preferred-install' => 'dist']]);
$this->assertEquals('dist', $config->get('preferred-install')); self::assertEquals('dist', $config->get('preferred-install'));
} }
public function testMergePreferredInstall(): void public function testMergePreferredInstall(): void
@ -161,7 +161,7 @@ class ConfigTest extends TestCase
// This assertion needs to make sure full wildcard preferences are placed last // This assertion needs to make sure full wildcard preferences are placed last
// Handled by composer because we convert string preferences for BC, all other // Handled by composer because we convert string preferences for BC, all other
// care for ordering and collision prevention is up to the user // 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 public function testMergeGithubOauth(): void
@ -170,7 +170,7 @@ class ConfigTest extends TestCase
$config->merge(['config' => ['github-oauth' => ['foo' => 'bar']]]); $config->merge(['config' => ['github-oauth' => ['foo' => 'bar']]]);
$config->merge(['config' => ['github-oauth' => ['bar' => 'baz']]]); $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 public function testVarReplacement(): void
@ -180,9 +180,9 @@ class ConfigTest extends TestCase
$config->merge(['config' => ['bin-dir' => '$HOME', 'cache-dir' => '~/foo/']]); $config->merge(['config' => ['bin-dir' => '$HOME', 'cache-dir' => '~/foo/']]);
$home = rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '\\/'); $home = rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '\\/');
$this->assertEquals('b', $config->get('c')); self::assertEquals('b', $config->get('c'));
$this->assertEquals($home, $config->get('bin-dir')); self::assertEquals($home, $config->get('bin-dir'));
$this->assertEquals($home.'/foo', $config->get('cache-dir')); self::assertEquals($home.'/foo', $config->get('cache-dir'));
} }
public function testRealpathReplacement(): void public function testRealpathReplacement(): void
@ -195,9 +195,9 @@ class ConfigTest extends TestCase
]]); ]]);
$home = rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '\\/'); $home = rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '\\/');
$this->assertEquals('/foo/bar/vendor', $config->get('vendor-dir')); self::assertEquals('/foo/bar/vendor', $config->get('vendor-dir'));
$this->assertEquals($home.'/foo', $config->get('bin-dir')); self::assertEquals($home.'/foo', $config->get('bin-dir'));
$this->assertEquals('/baz', $config->get('cache-dir')); self::assertEquals('/baz', $config->get('cache-dir'));
} }
public function testStreamWrapperDirs(): void public function testStreamWrapperDirs(): void
@ -207,7 +207,7 @@ class ConfigTest extends TestCase
'cache-dir' => 's3://baz/', 'cache-dir' => 's3://baz/',
]]); ]]);
$this->assertEquals('s3://baz', $config->get('cache-dir')); self::assertEquals('s3://baz', $config->get('cache-dir'));
} }
public function testFetchingRelativePaths(): void public function testFetchingRelativePaths(): void
@ -218,10 +218,10 @@ class ConfigTest extends TestCase
'vendor-dir' => 'vendor', 'vendor-dir' => 'vendor',
]]); ]]);
$this->assertEquals('/foo/bar/vendor', $config->get('vendor-dir')); self::assertEquals('/foo/bar/vendor', $config->get('vendor-dir'));
$this->assertEquals('/foo/bar/vendor/foo', $config->get('bin-dir')); self::assertEquals('/foo/bar/vendor/foo', $config->get('bin-dir'));
$this->assertEquals('vendor', $config->get('vendor-dir', Config::RELATIVE_PATHS)); self::assertEquals('vendor', $config->get('vendor-dir', Config::RELATIVE_PATHS));
$this->assertEquals('vendor/foo', $config->get('bin-dir', Config::RELATIVE_PATHS)); self::assertEquals('vendor/foo', $config->get('bin-dir', Config::RELATIVE_PATHS));
} }
public function testOverrideGithubProtocols(): void 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', 'ssh']]]);
$config->merge(['config' => ['github-protocols' => ['https']]]); $config->merge(['config' => ['github-protocols' => ['https']]]);
$this->assertEquals(['https'], $config->get('github-protocols')); self::assertEquals(['https'], $config->get('github-protocols'));
} }
public function testGitDisabledByDefaultInGithubProtocols(): void public function testGitDisabledByDefaultInGithubProtocols(): void
{ {
$config = new Config(false); $config = new Config(false);
$config->merge(['config' => ['github-protocols' => ['https', 'git']]]); $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]]); $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->merge(
['config' => ['disable-tls' => 'false']] ['config' => ['disable-tls' => 'false']]
); );
$this->assertFalse($config->get('disable-tls')); self::assertFalse($config->get('disable-tls'));
$config->merge( $config->merge(
['config' => ['disable-tls' => 'true']] ['config' => ['disable-tls' => 'true']]
); );
$this->assertTrue($config->get('disable-tls')); self::assertTrue($config->get('disable-tls'));
} }
public function testProcessTimeout(): void public function testProcessTimeout(): void
@ -344,7 +344,7 @@ class ConfigTest extends TestCase
$result = $config->get('process-timeout'); $result = $config->get('process-timeout');
Platform::clearEnv('COMPOSER_PROCESS_TIMEOUT'); Platform::clearEnv('COMPOSER_PROCESS_TIMEOUT');
$this->assertEquals(0, $result); self::assertEquals(0, $result);
} }
public function testHtaccessProtect(): void public function testHtaccessProtect(): void
@ -354,7 +354,7 @@ class ConfigTest extends TestCase
$result = $config->get('htaccess-protect'); $result = $config->get('htaccess-protect');
Platform::clearEnv('COMPOSER_HTACCESS_PROTECT'); Platform::clearEnv('COMPOSER_HTACCESS_PROTECT');
$this->assertEquals(0, $result); self::assertEquals(0, $result);
} }
public function testGetSourceOfValue(): void public function testGetSourceOfValue(): void
@ -363,14 +363,14 @@ class ConfigTest extends TestCase
$config = new Config; $config = new Config;
$this->assertSame(Config::SOURCE_DEFAULT, $config->getSourceOfValue('process-timeout')); self::assertSame(Config::SOURCE_DEFAULT, $config->getSourceOfValue('process-timeout'));
$config->merge( $config->merge(
['config' => ['process-timeout' => 1]], ['config' => ['process-timeout' => 1]],
'phpunit-test' 'phpunit-test'
); );
$this->assertSame('phpunit-test', $config->getSourceOfValue('process-timeout')); self::assertSame('phpunit-test', $config->getSourceOfValue('process-timeout'));
} }
public function testGetSourceOfValueEnvVariables(): void public function testGetSourceOfValueEnvVariables(): void
@ -380,7 +380,7 @@ class ConfigTest extends TestCase
$result = $config->getSourceOfValue('htaccess-protect'); $result = $config->getSourceOfValue('htaccess-protect');
Platform::clearEnv('COMPOSER_HTACCESS_PROTECT'); Platform::clearEnv('COMPOSER_HTACCESS_PROTECT');
$this->assertEquals('COMPOSER_HTACCESS_PROTECT', $result); self::assertEquals('COMPOSER_HTACCESS_PROTECT', $result);
} }
public function testAudit(): void public function testAudit(): void
@ -420,8 +420,8 @@ class ConfigTest extends TestCase
]; ];
foreach ($keys as $key) { foreach ($keys as $key) {
$value = $config->get($key); $value = $config->get($key);
$this->assertIsArray($value); // @phpstan-ignore staticMethod.dynamicCall (- PHPStan knows that its an array for all given keys) self::assertIsArray($value);
$this->assertCount(0, $value); self::assertCount(0, $value);
} }
} }
@ -429,29 +429,29 @@ class ConfigTest extends TestCase
{ {
$config = new Config(false); $config = new Config(false);
$config->merge(['config' => ['allow-plugins' => ['some/plugin' => true]]]); $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]]]); $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 public function testOverridesGlobalBooleanPluginsConfig(): void
{ {
$config = new Config(false); $config = new Config(false);
$config->merge(['config' => ['allow-plugins' => true]]); $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]]]); $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 public function testAllowsAllPluginsFromLocalBoolean(): void
{ {
$config = new Config(false); $config = new Config(false);
$config->merge(['config' => ['allow-plugins' => ['some/plugin' => true]]]); $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]]); $config->merge(['config' => ['allow-plugins' => true]]);
$this->assertEquals(true, $config->get('allow-plugins')); self::assertEquals(true, $config->get('allow-plugins'));
} }
} }

View File

@ -24,7 +24,7 @@ class HtmlOutputFormatterTest extends TestCase
'warning' => new OutputFormatterStyle('black', 'yellow'), 'warning' => new OutputFormatterStyle('black', 'yellow'),
]); ]);
$this->assertEquals( self::assertEquals(
'text <span style="color:green;">green</span> <span style="color:yellow;">yellow</span> <span style="color:black;background-color:yellow;">black w/ yello bg</span>', 'text <span style="color:green;">green</span> <span style="color:yellow;">yellow</span> <span style="color:black;background-color:yellow;">black w/ yello bg</span>',
$formatter->format('text <info>green</info> <comment>yellow</comment> <warning>black w/ yello bg</warning>') $formatter->format('text <info>green</info> <comment>yellow</comment> <warning>black w/ yello bg</warning>')
); );

View File

@ -22,6 +22,6 @@ class DefaultConfigTest extends TestCase
public function testDefaultValuesAreAsExpected(): void public function testDefaultValuesAreAsExpected(): void
{ {
$config = new Config; $config = new Config;
$this->assertFalse($config->get('disable-tls')); self::assertFalse($config->get('disable-tls'));
} }
} }

View File

@ -53,7 +53,7 @@ class DefaultPolicyTest extends TestCase
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectNewest(): void public function testSelectNewest(): void
@ -69,7 +69,7 @@ class DefaultPolicyTest extends TestCase
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectNewestPicksLatest(): void public function testSelectNewestPicksLatest(): void
@ -85,7 +85,7 @@ class DefaultPolicyTest extends TestCase
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectNewestPicksLatestStableWithPreferStable(): void public function testSelectNewestPicksLatestStableWithPreferStable(): void
@ -102,7 +102,7 @@ class DefaultPolicyTest extends TestCase
$policy = new DefaultPolicy(true); $policy = new DefaultPolicy(true);
$selected = $policy->selectPreferredPackages($pool, $literals); $selected = $policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectNewestWithDevPicksNonDev(): void public function testSelectNewestWithDevPicksNonDev(): void
@ -118,7 +118,7 @@ class DefaultPolicyTest extends TestCase
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectNewestWithPreferredVersionPicksPreferredVersionIfAvailable(): void public function testSelectNewestWithPreferredVersionPicksPreferredVersionIfAvailable(): void
@ -137,7 +137,7 @@ class DefaultPolicyTest extends TestCase
$policy = new DefaultPolicy(false, false, ['a' => '1.1.0.0']); $policy = new DefaultPolicy(false, false, ['a' => '1.1.0.0']);
$selected = $policy->selectPreferredPackages($pool, $literals); $selected = $policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectNewestWithPreferredVersionPicksNewestOtherwise(): void public function testSelectNewestWithPreferredVersionPicksNewestOtherwise(): void
@ -154,7 +154,7 @@ class DefaultPolicyTest extends TestCase
$policy = new DefaultPolicy(false, false, ['a' => '1.1.0.0']); $policy = new DefaultPolicy(false, false, ['a' => '1.1.0.0']);
$selected = $policy->selectPreferredPackages($pool, $literals); $selected = $policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectNewestWithPreferredVersionPicksLowestIfPreferLowest(): void public function testSelectNewestWithPreferredVersionPicksLowestIfPreferLowest(): void
@ -171,7 +171,7 @@ class DefaultPolicyTest extends TestCase
$policy = new DefaultPolicy(false, true, ['a' => '1.1.0.0']); $policy = new DefaultPolicy(false, true, ['a' => '1.1.0.0']);
$selected = $policy->selectPreferredPackages($pool, $literals); $selected = $policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testRepositoryOrderingAffectsPriority(): void public function testRepositoryOrderingAffectsPriority(): void
@ -193,7 +193,7 @@ class DefaultPolicyTest extends TestCase
$expected = [$package2->getId()]; $expected = [$package2->getId()];
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
$this->repositorySet = new RepositorySet('dev'); $this->repositorySet = new RepositorySet('dev');
$this->repositorySet->addRepository($repo2); $this->repositorySet->addRepository($repo2);
@ -204,7 +204,7 @@ class DefaultPolicyTest extends TestCase
$expected = [$package4->getId()]; $expected = [$package4->getId()];
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectLocalReposFirst(): void public function testSelectLocalReposFirst(): void
@ -235,7 +235,7 @@ class DefaultPolicyTest extends TestCase
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectAllProviders(): void public function testSelectAllProviders(): void
@ -255,7 +255,7 @@ class DefaultPolicyTest extends TestCase
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testPreferNonReplacingFromSameRepo(): void public function testPreferNonReplacingFromSameRepo(): void
@ -274,7 +274,7 @@ class DefaultPolicyTest extends TestCase
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testPreferReplacingPackageFromSameVendor(): void public function testPreferReplacingPackageFromSameVendor(): void
@ -294,7 +294,7 @@ class DefaultPolicyTest extends TestCase
$expected = $literals; $expected = $literals;
$selected = $this->policy->selectPreferredPackages($pool, $literals, 'vendor-a/package'); $selected = $this->policy->selectPreferredPackages($pool, $literals, 'vendor-a/package');
$this->assertEquals($expected, $selected); self::assertEquals($expected, $selected);
// test with reversed order in repo // test with reversed order in repo
$repo = new ArrayRepository; $repo = new ArrayRepository;
@ -310,7 +310,7 @@ class DefaultPolicyTest extends TestCase
$expected = $literals; $expected = $literals;
$selected = $this->policy->selectPreferredPackages($pool, $literals, 'vendor-a/package'); $selected = $this->policy->selectPreferredPackages($pool, $literals, 'vendor-a/package');
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
public function testSelectLowest(): void public function testSelectLowest(): void
@ -328,6 +328,6 @@ class DefaultPolicyTest extends TestCase
$selected = $policy->selectPreferredPackages($pool, $literals); $selected = $policy->selectPreferredPackages($pool, $literals);
$this->assertSame($expected, $selected); self::assertSame($expected, $selected);
} }
} }

View File

@ -139,13 +139,13 @@ class PoolBuilderTest extends TestCase
sort($expect); sort($expect);
sort($result); 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()); $optimizer = new PoolOptimizer(new DefaultPolicy());
$result = $this->getPackageResultSet($optimizer->optimize($request, $pool), $packageIds); $result = $this->getPackageResultSet($optimizer->optimize($request, $pool), $packageIds);
sort($expectOptimized); sort($expectOptimized);
sort($result); 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); chdir($oldCwd);
} }

View File

@ -63,7 +63,7 @@ class PoolOptimizerTest extends TestCase
$pool = $poolOptimizer->optimize($request, $pool); $pool = $poolOptimizer->optimize($request, $pool);
$this->assertSame( self::assertSame(
$this->reducePackagesInfoForComparison($expectedPackages), $this->reducePackagesInfoForComparison($expectedPackages),
$this->reducePackagesInfoForComparison($pool->getPackages()), $this->reducePackagesInfoForComparison($pool->getPackages()),
$message $message

View File

@ -23,8 +23,8 @@ class PoolTest extends TestCase
$pool = $this->createPool([$package]); $pool = $this->createPool([$package]);
$this->assertEquals([$package], $pool->whatProvides('foo')); self::assertEquals([$package], $pool->whatProvides('foo'));
$this->assertEquals([$package], $pool->whatProvides('foo')); self::assertEquals([$package], $pool->whatProvides('foo'));
} }
public function testWhatProvidesPackageWithConstraint(): void public function testWhatProvidesPackageWithConstraint(): void
@ -37,8 +37,8 @@ class PoolTest extends TestCase
$secondPackage, $secondPackage,
]); ]);
$this->assertEquals([$firstPackage, $secondPackage], $pool->whatProvides('foo')); self::assertEquals([$firstPackage, $secondPackage], $pool->whatProvides('foo'));
$this->assertEquals([$secondPackage], $pool->whatProvides('foo', self::getVersionConstraint('==', '2'))); self::assertEquals([$secondPackage], $pool->whatProvides('foo', self::getVersionConstraint('==', '2')));
} }
public function testPackageById(): void public function testPackageById(): void
@ -47,14 +47,14 @@ class PoolTest extends TestCase
$pool = $this->createPool([$package]); $pool = $this->createPool([$package]);
$this->assertSame($package, $pool->packageById(1)); self::assertSame($package, $pool->packageById(1));
} }
public function testWhatProvidesWhenPackageCannotBeFound(): void public function testWhatProvidesWhenPackageCannotBeFound(): void
{ {
$pool = $this->createPool(); $pool = $this->createPool();
$this->assertEquals([], $pool->whatProvides('foo')); self::assertEquals([], $pool->whatProvides('foo'));
} }
/** /**

View File

@ -33,7 +33,7 @@ class RequestTest extends TestCase
$request = new Request(); $request = new Request();
$request->requireName('foo'); $request->requireName('foo');
$this->assertEquals( self::assertEquals(
[ [
'foo' => new MatchAllConstraint(), 'foo' => new MatchAllConstraint(),
], ],
@ -55,7 +55,7 @@ class RequestTest extends TestCase
$request = new Request(); $request = new Request();
$request->requireName('foo', $constraint = self::getVersionConstraint('=', '1')); $request->requireName('foo', $constraint = self::getVersionConstraint('=', '1'));
$this->assertEquals( self::assertEquals(
[ [
'foo' => $constraint, 'foo' => $constraint,
], ],

View File

@ -58,7 +58,7 @@ class RuleSetIteratorTest extends TestCase
$this->rules[RuleSet::TYPE_LEARNED][0], $this->rules[RuleSet::TYPE_LEARNED][0],
]; ];
$this->assertEquals($expected, $result); self::assertEquals($expected, $result);
} }
public function testKeys(): void public function testKeys(): void
@ -76,6 +76,6 @@ class RuleSetIteratorTest extends TestCase
RuleSet::TYPE_LEARNED, RuleSet::TYPE_LEARNED,
]; ];
$this->assertEquals($expected, $result); self::assertEquals($expected, $result);
} }
} }

View File

@ -41,7 +41,7 @@ class RuleSetTest extends TestCase
$ruleSet->add($rules[RuleSet::TYPE_LEARNED][0], RuleSet::TYPE_LEARNED); $ruleSet->add($rules[RuleSet::TYPE_LEARNED][0], RuleSet::TYPE_LEARNED);
$ruleSet->add($rules[RuleSet::TYPE_REQUEST][1], RuleSet::TYPE_REQUEST); $ruleSet->add($rules[RuleSet::TYPE_REQUEST][1], RuleSet::TYPE_REQUEST);
$this->assertEquals($rules, $ruleSet->getRules()); self::assertEquals($rules, $ruleSet->getRules());
} }
public function testAddIgnoresDuplicates(): void 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][1], RuleSet::TYPE_REQUEST);
$ruleSet->add($rules[RuleSet::TYPE_REQUEST][2], 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 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([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); $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 public function testRuleById(): void
@ -89,7 +89,7 @@ class RuleSetTest extends TestCase
$rule = new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $rule = new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]);
$ruleSet->add($rule, RuleSet::TYPE_REQUEST); $ruleSet->add($rule, RuleSet::TYPE_REQUEST);
$this->assertSame($rule, $ruleSet->ruleById[0]); self::assertSame($rule, $ruleSet->ruleById[0]);
} }
public function testGetIterator(): void public function testGetIterator(): void
@ -103,9 +103,9 @@ class RuleSetTest extends TestCase
$iterator = $ruleSet->getIterator(); $iterator = $ruleSet->getIterator();
$this->assertSame($rule1, $iterator->current()); self::assertSame($rule1, $iterator->current());
$iterator->next(); $iterator->next();
$this->assertSame($rule2, $iterator->current()); self::assertSame($rule2, $iterator->current());
} }
public function testGetIteratorFor(): void public function testGetIteratorFor(): void
@ -119,7 +119,7 @@ class RuleSetTest extends TestCase
$iterator = $ruleSet->getIteratorFor(RuleSet::TYPE_LEARNED); $iterator = $ruleSet->getIteratorFor(RuleSet::TYPE_LEARNED);
$this->assertSame($rule2, $iterator->current()); self::assertSame($rule2, $iterator->current());
} }
public function testGetIteratorWithout(): void public function testGetIteratorWithout(): void
@ -133,7 +133,7 @@ class RuleSetTest extends TestCase
$iterator = $ruleSet->getIteratorWithout(RuleSet::TYPE_REQUEST); $iterator = $ruleSet->getIteratorWithout(RuleSet::TYPE_REQUEST);
$this->assertSame($rule2, $iterator->current()); self::assertSame($rule2, $iterator->current());
} }
public function testPrettyString(): void public function testPrettyString(): void
@ -151,6 +151,6 @@ class RuleSetTest extends TestCase
$ruleSet->add($rule, RuleSet::TYPE_REQUEST); $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));
} }
} }

View File

@ -27,7 +27,7 @@ class RuleTest extends TestCase
$rule = new GenericRule([123], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $rule = new GenericRule([123], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]);
$hash = unpack('ihash', md5('123', true)); $hash = unpack('ihash', md5('123', true));
$this->assertEquals($hash['hash'], $rule->getHash()); self::assertEquals($hash['hash'], $rule->getHash());
} }
public function testEqualsForRulesWithDifferentHashes(): void 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]); $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]); $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 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]); $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]); $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 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]); $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]); $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 public function testSetAndGetType(): void
@ -59,7 +59,7 @@ class RuleTest extends TestCase
$rule = new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]); $rule = new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]);
$rule->setType(RuleSet::TYPE_REQUEST); $rule->setType(RuleSet::TYPE_REQUEST);
$this->assertEquals(RuleSet::TYPE_REQUEST, $rule->getType()); self::assertEquals(RuleSet::TYPE_REQUEST, $rule->getType());
} }
public function testEnable(): void public function testEnable(): void
@ -68,8 +68,8 @@ class RuleTest extends TestCase
$rule->disable(); $rule->disable();
$rule->enable(); $rule->enable();
$this->assertTrue($rule->isEnabled()); self::assertTrue($rule->isEnabled());
$this->assertFalse($rule->isDisabled()); self::assertFalse($rule->isDisabled());
} }
public function testDisable(): void public function testDisable(): void
@ -78,8 +78,8 @@ class RuleTest extends TestCase
$rule->enable(); $rule->enable();
$rule->disable(); $rule->disable();
$this->assertTrue($rule->isDisabled()); self::assertTrue($rule->isDisabled());
$this->assertFalse($rule->isEnabled()); self::assertFalse($rule->isEnabled());
} }
public function testIsAssertions(): void 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]); $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]); $rule2 = new GenericRule([1], Rule::RULE_ROOT_REQUIRE, ['packageName' => '', 'constraint' => new MatchAllConstraint]);
$this->assertFalse($rule->isAssertion()); self::assertFalse($rule->isAssertion());
$this->assertTrue($rule2->isAssertion()); self::assertTrue($rule2->isAssertion());
} }
public function testPrettyString(): void 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)); $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));
} }
} }

View File

@ -94,9 +94,9 @@ class SolverTest extends TestCase
$this->fail('Unsolvable conflict did not result in exception.'); $this->fail('Unsolvable conflict did not result in exception.');
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {
$problems = $e->getProblems(); $problems = $e->getProblems();
$this->assertCount(1, $problems); self::assertCount(1, $problems);
$this->assertEquals(2, $e->getCode()); self::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::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.'); $this->fail('Unsolvable conflict did not result in exception.');
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {
$problems = $e->getProblems(); $problems = $e->getProblems();
$this->assertCount(1, $problems); self::assertCount(1, $problems);
$msg = "\n"; $msg = "\n";
$msg .= " Problem 1\n"; $msg .= " Problem 1\n";
$msg .= " - Root composer.json requires a * -> satisfiable by A[1.0].\n"; $msg .= " - Root composer.json requires a * -> satisfiable by A[1.0].\n";
$msg .= " - A 1.0 conflicts with B 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"; $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.'); $this->fail('Unsolvable conflict did not result in exception.');
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {
$problems = $e->getProblems(); $problems = $e->getProblems();
$this->assertCount(1, $problems); self::assertCount(1, $problems);
// TODO assert problem properties // TODO assert problem properties
$msg = "\n"; $msg = "\n";
$msg .= " Problem 1\n"; $msg .= " Problem 1\n";
$msg .= " - Root composer.json requires a * -> satisfiable by A[1.0].\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"; $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.'); $this->fail('Unsolvable conflict did not result in exception.');
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {
$problems = $e->getProblems(); $problems = $e->getProblems();
$this->assertCount(1, $problems); self::assertCount(1, $problems);
$msg = "\n"; $msg = "\n";
$msg .= " Problem 1\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 .= " - 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 .= " - 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"; $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(); $this->createSolver();
// check correct setup for assertion later // check correct setup for assertion later
$this->assertFalse($this->solver->testFlagLearnedPositiveLiteral); self::assertFalse($this->solver->testFlagLearnedPositiveLiteral);
$this->checkSolverResult([ $this->checkSolverResult([
['job' => 'install', 'package' => $packageF1], ['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 // verify that the code path leading to a negative literal resulting in a positive learned literal is actually
// executed // executed
$this->assertTrue($this->solver->testFlagLearnedPositiveLiteral); self::assertTrue($this->solver->testFlagLearnedPositiveLiteral);
} }
protected function reposComplete(): void protected function reposComplete(): void
@ -1094,7 +1094,7 @@ class SolverTest extends TestCase
$resultReadable[] = array_map('strval', $op); $resultReadable[] = array_map('strval', $op);
} }
$this->assertEquals($expectedReadable, $resultReadable); self::assertEquals($expectedReadable, $resultReadable);
$this->assertEquals($expected, $result); self::assertEquals($expected, $result);
} }
} }

View File

@ -122,6 +122,6 @@ class TransactionTest extends TestCase
} }
} }
$this->assertEquals($expected, $result); self::assertEquals($expected, $result);
} }
} }

View File

@ -37,8 +37,8 @@ class ArchiveDownloaderTest extends TestCase
->will($this->returnValue('/vendor')); ->will($this->returnValue('/vendor'));
$first = $method->invoke($downloader, $packageMock, '/path'); $first = $method->invoke($downloader, $packageMock, '/path');
$this->assertMatchesRegularExpression('#/vendor/composer/tmp-[a-z0-9]+\.js#', $first); self::assertMatchesRegularExpression('#/vendor/composer/tmp-[a-z0-9]+\.js#', $first);
$this->assertSame($first, $method->invoke($downloader, $packageMock, '/path')); self::assertSame($first, $method->invoke($downloader, $packageMock, '/path'));
} }
public function testProcessUrl(): void public function testProcessUrl(): void
@ -54,7 +54,7 @@ class ArchiveDownloaderTest extends TestCase
$expected = 'https://github.com/composer/composer/zipball/master'; $expected = 'https://github.com/composer/composer/zipball/master';
$url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected); $url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected);
$this->assertEquals($expected, $url); self::assertEquals($expected, $url);
} }
public function testProcessUrl2(): void public function testProcessUrl2(): void
@ -70,7 +70,7 @@ class ArchiveDownloaderTest extends TestCase
$expected = 'https://github.com/composer/composer/archive/master.tar.gz'; $expected = 'https://github.com/composer/composer/archive/master.tar.gz';
$url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected); $url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected);
$this->assertEquals($expected, $url); self::assertEquals($expected, $url);
} }
public function testProcessUrl3(): void public function testProcessUrl3(): void
@ -86,7 +86,7 @@ class ArchiveDownloaderTest extends TestCase
$expected = 'https://api.github.com/repos/composer/composer/zipball/master'; $expected = 'https://api.github.com/repos/composer/composer/zipball/master';
$url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected); $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')); ->will($this->returnValue('ref'));
$url = $method->invoke($downloader, $package, $url); $url = $method->invoke($downloader, $package, $url);
$this->assertEquals($expected, $url); self::assertEquals($expected, $url);
} }
public static function provideUrls(): array public static function provideUrls(): array
@ -148,7 +148,7 @@ class ArchiveDownloaderTest extends TestCase
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
$url = $method->invoke($downloader, $package, $url); $url = $method->invoke($downloader, $package, $url);
$this->assertEquals($expected, $url); self::assertEquals($expected, $url);
} }
public static function provideBitbucketUrls(): array public static function provideBitbucketUrls(): array

View File

@ -36,7 +36,7 @@ class DownloadManagerTest extends TestCase
$manager = new DownloadManager($this->io, false, $this->filesystem); $manager = new DownloadManager($this->io, false, $this->filesystem);
$manager->setDownloader('test', $downloader); $manager->setDownloader('test', $downloader);
$this->assertSame($downloader, $manager->getDownloader('test')); self::assertSame($downloader, $manager->getDownloader('test'));
self::expectException('InvalidArgumentException'); self::expectException('InvalidArgumentException');
$manager->getDownloader('unregistered'); $manager->getDownloader('unregistered');
@ -86,7 +86,7 @@ class DownloadManagerTest extends TestCase
->with('pear') ->with('pear')
->will($this->returnValue($downloader)); ->will($this->returnValue($downloader));
$this->assertSame($downloader, $manager->getDownloaderForPackage($package)); self::assertSame($downloader, $manager->getDownloaderForPackage($package));
} }
public function testGetDownloaderForIncorrectlyInstalledDistPackage(): void public function testGetDownloaderForIncorrectlyInstalledDistPackage(): void
@ -152,7 +152,7 @@ class DownloadManagerTest extends TestCase
->with('git') ->with('git')
->will($this->returnValue($downloader)); ->will($this->returnValue($downloader));
$this->assertSame($downloader, $manager->getDownloaderForPackage($package)); self::assertSame($downloader, $manager->getDownloaderForPackage($package));
} }
public function testGetDownloaderForIncorrectlyInstalledSourcePackage(): void public function testGetDownloaderForIncorrectlyInstalledSourcePackage(): void
@ -199,7 +199,7 @@ class DownloadManagerTest extends TestCase
$manager = new DownloadManager($this->io, false, $this->filesystem); $manager = new DownloadManager($this->io, false, $this->filesystem);
$this->assertNull($manager->getDownloaderForPackage($package)); self::assertNull($manager->getDownloaderForPackage($package));
} }
public function testFullPackageDownload(): void public function testFullPackageDownload(): void
@ -264,7 +264,7 @@ class DownloadManagerTest extends TestCase
'source', 'source',
]; ];
$this->assertSame(array_shift($series), $type); self::assertSame(array_shift($series), $type);
}); });
$downloaderFail = $this->createDownloaderMock(); $downloaderFail = $this->createDownloaderMock();
@ -674,7 +674,7 @@ class DownloadManagerTest extends TestCase
$manager = new DownloadManager($this->io, false, $this->filesystem); $manager = new DownloadManager($this->io, false, $this->filesystem);
$method = new \ReflectionMethod($manager, 'getAvailableSources'); $method = new \ReflectionMethod($manager, 'getAvailableSources');
$method->setAccessible(true); $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 public static function updatesProvider(): array

View File

@ -81,8 +81,8 @@ class FileDownloaderTest extends TestCase
} elseif (is_file($path)) { } elseif (is_file($path)) {
unlink($path); unlink($path);
} }
$this->assertInstanceOf('RuntimeException', $e); self::assertInstanceOf('RuntimeException', $e);
$this->assertStringContainsString('exists and is not a directory', $e->getMessage()); self::assertStringContainsString('exists and is not a directory', $e->getMessage());
} }
} }
@ -96,7 +96,7 @@ class FileDownloaderTest extends TestCase
$method = new \ReflectionMethod($downloader, 'getFileName'); $method = new \ReflectionMethod($downloader, 'getFileName');
$method->setAccessible(true); $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 public function testDownloadButFileIsUnsaved(): void
@ -134,8 +134,8 @@ class FileDownloaderTest extends TestCase
unlink($path); unlink($path);
} }
$this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); self::assertInstanceOf('UnexpectedValueException', $e, $e->getMessage());
$this->assertStringContainsString('could not be saved to', $e->getMessage()); self::assertStringContainsString('could not be saved to', $e->getMessage());
} }
} }
@ -176,7 +176,7 @@ class FileDownloaderTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('copyTo') ->method('copyTo')
->will($this->returnCallback(function ($cacheKey) use ($expectedCacheKey): bool { ->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; return false;
})); }));
@ -184,7 +184,7 @@ class FileDownloaderTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('copyFrom') ->method('copyFrom')
->will($this->returnCallback(function ($cacheKey) use ($expectedCacheKey): bool { ->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; return false;
})); }));
@ -194,7 +194,7 @@ class FileDownloaderTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('addCopy') ->method('addCopy')
->will($this->returnCallback(function ($url) use ($expectedUrl) { ->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( return \React\Promise\resolve(
new Response(['url' => 'http://example.org/'], 200, [], 'file~') new Response(['url' => 'http://example.org/'], 200, [], 'file~')
@ -217,8 +217,8 @@ class FileDownloaderTest extends TestCase
unlink($path); unlink($path);
} }
$this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); self::assertInstanceOf('UnexpectedValueException', $e, $e->getMessage());
$this->assertStringContainsString('could not be saved to', $e->getMessage()); self::assertStringContainsString('could not be saved to', $e->getMessage());
} }
} }
@ -260,7 +260,7 @@ class FileDownloaderTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('copyTo') ->method('copyTo')
->will($this->returnCallback(function ($cacheKey) use ($expectedCacheKey): bool { ->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; return false;
})); }));
@ -268,7 +268,7 @@ class FileDownloaderTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('copyFrom') ->method('copyFrom')
->will($this->returnCallback(function ($cacheKey) use ($expectedCacheKey): bool { ->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; return false;
})); }));
@ -278,7 +278,7 @@ class FileDownloaderTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('addCopy') ->method('addCopy')
->will($this->returnCallback(function ($url) use ($expectedUrl) { ->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( return \React\Promise\resolve(
new Response(['url' => 'http://example.org/'], 200, [], 'file~') new Response(['url' => 'http://example.org/'], 200, [], 'file~')
@ -301,8 +301,8 @@ class FileDownloaderTest extends TestCase
unlink($path); unlink($path);
} }
$this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); self::assertInstanceOf('UnexpectedValueException', $e, $e->getMessage());
$this->assertStringContainsString('could not be saved to', $e->getMessage()); self::assertStringContainsString('could not be saved to', $e->getMessage());
} }
} }
@ -364,8 +364,8 @@ class FileDownloaderTest extends TestCase
unlink($path); unlink($path);
} }
$this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage()); self::assertInstanceOf('UnexpectedValueException', $e, $e->getMessage());
$this->assertStringContainsString('checksum verification', $e->getMessage()); self::assertStringContainsString('checksum verification', $e->getMessage());
} }
} }

View File

@ -162,6 +162,6 @@ class FossilDownloaderTest extends TestCase
{ {
$downloader = $this->getDownloaderMock(null); $downloader = $this->getDownloaderMock(null);
$this->assertEquals('source', $downloader->getInstallationSource()); self::assertEquals('source', $downloader->getInstallationSource());
} }
} }

View File

@ -304,7 +304,7 @@ class GitDownloaderTest extends TestCase
if ('RuntimeException' !== get_class($e)) { if ('RuntimeException' !== get_class($e)) {
throw $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)) { if ('RuntimeException' !== get_class($e)) {
throw $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(); $downloader = $this->getDownloaderMock();
$this->assertEquals('source', $downloader->getInstallationSource()); self::assertEquals('source', $downloader->getInstallationSource());
} }
private function winCompat(string $cmd): string private function winCompat(string $cmd): string

View File

@ -154,6 +154,6 @@ class HgDownloaderTest extends TestCase
{ {
$downloader = $this->getDownloaderMock(null); $downloader = $this->getDownloaderMock(null);
$this->assertEquals('source', $downloader->getInstallationSource()); self::assertEquals('source', $downloader->getInstallationSource());
} }
} }

View File

@ -66,7 +66,7 @@ class XzDownloaderTest extends TestCase
$this->fail('Download of invalid tarball should throw an exception'); $this->fail('Download of invalid tarball should throw an exception');
} catch (\RuntimeException $e) { } 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());
} }
} }
} }

View File

@ -102,7 +102,7 @@ class ZipDownloaderTest extends TestCase
$this->fail('Download of invalid zip files should throw an exception'); $this->fail('Download of invalid zip files should throw an exception');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertStringContainsString('is not a zip archive', $e->getMessage()); self::assertStringContainsString('is not a zip archive', $e->getMessage());
} }
} }

View File

@ -200,7 +200,7 @@ class EventDispatcherTest extends TestCase
.'> ev1: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL .'> ev1: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL
.'> ev2: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL .'> ev2: 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->removeListener($this);
$dispatcher->dispatch('ev1'); $dispatcher->dispatch('ev1');
@ -208,7 +208,7 @@ class EventDispatcherTest extends TestCase
$expected .= '> ev1: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL $expected .= '> 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());
} }
public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack(): void public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack(): void
@ -245,7 +245,7 @@ class EventDispatcherTest extends TestCase
$expected = '> post-install-cmd: echo -n foo'.PHP_EOL. $expected = '> post-install-cmd: echo -n foo'.PHP_EOL.
'> post-install-cmd: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL. '> post-install-cmd: Composer\Test\EventDispatcher\EventDispatcherTest::someMethod'.PHP_EOL.
'> post-install-cmd: echo -n bar'.PHP_EOL; '> post-install-cmd: echo -n bar'.PHP_EOL;
$this->assertEquals($expected, $io->getOutput()); self::assertEquals($expected, $io->getOutput());
} }
public function testDispatcherCanPutEnv(): void public function testDispatcherCanPutEnv(): void
@ -274,7 +274,7 @@ class EventDispatcherTest extends TestCase
$expected = '> post-install-cmd: @putenv ABC=123'.PHP_EOL. $expected = '> post-install-cmd: @putenv ABC=123'.PHP_EOL.
'> post-install-cmd: Composer\Test\EventDispatcher\EventDispatcherTest::getTestEnv'.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 public function testDispatcherAppendsDirBinOnPathForEveryListener(): void
@ -386,7 +386,7 @@ class EventDispatcherTest extends TestCase
'> group: @subgroup'.PHP_EOL. '> group: @subgroup'.PHP_EOL.
'> subgroup: echo -n baz'.PHP_EOL. '> subgroup: echo -n baz'.PHP_EOL.
'> group: echo -n bar'.PHP_EOL; '> group: echo -n bar'.PHP_EOL;
$this->assertEquals($expected, $io->getOutput()); self::assertEquals($expected, $io->getOutput());
} }
public function testRecursionInScriptsNames(): void public function testRecursionInScriptsNames(): void
@ -425,7 +425,7 @@ class EventDispatcherTest extends TestCase
$expected = "> helloWorld: @hello World".PHP_EOL. $expected = "> helloWorld: @hello World".PHP_EOL.
"> hello: echo Hello " .self::getCmd("'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 public function testDispatcherDetectInfiniteRecursion(): void

View File

@ -24,8 +24,8 @@ final class IgnoreAllPlatformRequirementFilterTest extends TestCase
{ {
$platformRequirementFilter = new IgnoreAllPlatformRequirementFilter(); $platformRequirementFilter = new IgnoreAllPlatformRequirementFilter();
$this->assertSame($expectIgnored, $platformRequirementFilter->isIgnored($req)); self::assertSame($expectIgnored, $platformRequirementFilter->isIgnored($req));
$this->assertSame($expectIgnored, $platformRequirementFilter->isUpperBoundIgnored($req)); self::assertSame($expectIgnored, $platformRequirementFilter->isUpperBoundIgnored($req));
} }
/** /**

View File

@ -26,7 +26,7 @@ final class IgnoreListPlatformRequirementFilterTest extends TestCase
{ {
$platformRequirementFilter = new IgnoreListPlatformRequirementFilter($reqList); $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); $platformRequirementFilter = new IgnoreListPlatformRequirementFilter($reqList);
$this->assertSame($expectIgnored, $platformRequirementFilter->isUpperBoundIgnored($req)); self::assertSame($expectIgnored, $platformRequirementFilter->isUpperBoundIgnored($req));
} }
/** /**

View File

@ -24,8 +24,8 @@ final class IgnoreNothingPlatformRequirementFilterTest extends TestCase
{ {
$platformRequirementFilter = new IgnoreNothingPlatformRequirementFilter(); $platformRequirementFilter = new IgnoreNothingPlatformRequirementFilter();
$this->assertFalse($platformRequirementFilter->isIgnored($req)); // @phpstan-ignore staticMethod.dynamicCall self::assertFalse($platformRequirementFilter->isIgnored($req));
$this->assertFalse($platformRequirementFilter->isUpperBoundIgnored($req)); // @phpstan-ignore staticMethod.dynamicCall self::assertFalse($platformRequirementFilter->isUpperBoundIgnored($req));
} }
/** /**

View File

@ -25,7 +25,7 @@ final class PlatformRequirementFilterFactoryTest extends TestCase
*/ */
public function testFromBoolOrList($boolOrList, $expectedInstance): void 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(); $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreAll();
$this->assertInstanceOf('Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter', $platformRequirementFilter); self::assertInstanceOf('Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter', $platformRequirementFilter);
} }
public function testIgnoreNothing(): void public function testIgnoreNothing(): void
{ {
$platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing(); $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
$this->assertInstanceOf('Composer\Filter\PlatformRequirementFilter\IgnoreNothingPlatformRequirementFilter', $platformRequirementFilter); self::assertInstanceOf('Composer\Filter\PlatformRequirementFilter\IgnoreNothingPlatformRequirementFilter', $platformRequirementFilter);
} }
} }

View File

@ -37,8 +37,8 @@ class BufferIOTest extends TestCase
'', '',
]); ]);
$this->assertTrue($bufferIO->askConfirmation('Please say yes!', false)); self::assertTrue($bufferIO->askConfirmation('Please say yes!', false));
$this->assertFalse($bufferIO->askConfirmation('Now please say no!', true)); self::assertFalse($bufferIO->askConfirmation('Now please say no!', true));
$this->assertSame('default', $bufferIO->ask('Empty string last', 'default')); self::assertSame('default', $bufferIO->ask('Empty string last', 'default'));
} }
} }

View File

@ -34,8 +34,8 @@ class ConsoleIOTest extends TestCase
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$this->assertTrue($consoleIO->isInteractive()); self::assertTrue($consoleIO->isInteractive());
$this->assertFalse($consoleIO->isInteractive()); self::assertFalse($consoleIO->isInteractive());
} }
public function testWrite(): void public function testWrite(): void
@ -127,7 +127,7 @@ class ConsoleIOTest extends TestCase
} }
if (count($series) > 0) { 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); $consoleIO = new ConsoleIO($inputMock, $outputMock, $setMock);
$result = $consoleIO->select('Select item', ["item1", "item2"], 'item1', false, "Error message", true); $result = $consoleIO->select('Select item', ["item1", "item2"], 'item1', false, "Error message", true);
$this->assertEquals(['1'], $result); self::assertEquals(['1'], $result);
} }
public function testSetAndgetAuthentication(): void public function testSetAndgetAuthentication(): void
@ -264,7 +264,7 @@ class ConsoleIOTest extends TestCase
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd');
$this->assertEquals( self::assertEquals(
['username' => 'l3l0', 'password' => 'passwd'], ['username' => 'l3l0', 'password' => 'passwd'],
$consoleIO->getAuthentication('repoName') $consoleIO->getAuthentication('repoName')
); );
@ -278,7 +278,7 @@ class ConsoleIOTest extends TestCase
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$this->assertEquals( self::assertEquals(
['username' => null, 'password' => null], ['username' => null, 'password' => null],
$consoleIO->getAuthentication('repoName') $consoleIO->getAuthentication('repoName')
); );
@ -293,7 +293,7 @@ class ConsoleIOTest extends TestCase
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd');
$this->assertTrue($consoleIO->hasAuthentication('repoName')); self::assertTrue($consoleIO->hasAuthentication('repoName'));
$this->assertFalse($consoleIO->hasAuthentication('repoName2')); self::assertFalse($consoleIO->hasAuthentication('repoName2'));
} }
} }

View File

@ -21,51 +21,51 @@ class NullIOTest extends TestCase
{ {
$io = new NullIO(); $io = new NullIO();
$this->assertFalse($io->isInteractive()); self::assertFalse($io->isInteractive());
} }
public function testhasAuthentication(): void public function testhasAuthentication(): void
{ {
$io = new NullIO(); $io = new NullIO();
$this->assertFalse($io->hasAuthentication('foo')); self::assertFalse($io->hasAuthentication('foo'));
} }
public function testAskAndHideAnswer(): void public function testAskAndHideAnswer(): void
{ {
$io = new NullIO(); $io = new NullIO();
$this->assertNull($io->askAndHideAnswer('foo')); self::assertNull($io->askAndHideAnswer('foo'));
} }
public function testgetAuthentications(): void public function testgetAuthentications(): void
{ {
$io = new NullIO(); $io = new NullIO();
$this->assertIsArray($io->getAuthentications()); // @phpstan-ignore staticMethod.dynamicCall self::assertIsArray($io->getAuthentications());
$this->assertEmpty($io->getAuthentications()); self::assertEmpty($io->getAuthentications());
$this->assertEquals(['username' => null, 'password' => null], $io->getAuthentication('foo')); self::assertEquals(['username' => null, 'password' => null], $io->getAuthentication('foo'));
} }
public function testAsk(): void public function testAsk(): void
{ {
$io = new NullIO(); $io = new NullIO();
$this->assertEquals('foo', $io->ask('bar', 'foo')); self::assertEquals('foo', $io->ask('bar', 'foo'));
} }
public function testAskConfirmation(): void public function testAskConfirmation(): void
{ {
$io = new NullIO(); $io = new NullIO();
$this->assertEquals(false, $io->askConfirmation('bar', false)); self::assertEquals(false, $io->askConfirmation('bar', false));
} }
public function testAskAndValidate(): void public function testAskAndValidate(): void
{ {
$io = new NullIO(); $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; return true;
}, null, 'foo')); }, null, 'foo'));
} }
@ -74,6 +74,6 @@ class NullIOTest extends TestCase
{ {
$io = new NullIO(); $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));
} }
} }

View File

@ -65,7 +65,7 @@ class InstalledVersionsTest extends TestCase
'foo/replaced', 'foo/replaced',
'meta/package', '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 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 public static function isInstalledProvider(): array
@ -95,7 +95,7 @@ class InstalledVersionsTest extends TestCase
*/ */
public function testSatisfies(bool $expected, string $name, string $constraint): void 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 public static function satisfiesProvider(): array
@ -133,7 +133,7 @@ class InstalledVersionsTest extends TestCase
*/ */
public function testGetVersionRanges(string $expected, string $name): void 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 public static function getVersionRangesProvider(): array
@ -155,7 +155,7 @@ class InstalledVersionsTest extends TestCase
*/ */
public function testGetVersion(?string $expected, string $name): void 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 public static function getVersionProvider(): array
@ -177,7 +177,7 @@ class InstalledVersionsTest extends TestCase
*/ */
public function testGetPrettyVersion(?string $expected, string $name): void 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 public static function getPrettyVersionProvider(): array
@ -202,7 +202,7 @@ class InstalledVersionsTest extends TestCase
public function testGetRootPackage(): void public function testGetRootPackage(): void
{ {
$this->assertSame([ self::assertSame([
'name' => '__root__', 'name' => '__root__',
'pretty_version' => 'dev-master', 'pretty_version' => 'dev-master',
'version' => 'dev-master', 'version' => 'dev-master',
@ -222,7 +222,7 @@ class InstalledVersionsTest extends TestCase
public function testGetRawData(): void public function testGetRawData(): void
{ {
$dir = $this->root; $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 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 public static function getReferenceProvider(): array
@ -257,13 +257,13 @@ class InstalledVersionsTest extends TestCase
'c/c', 'c/c',
]; ];
$this->assertSame($names, \Composer\InstalledVersions::getInstalledPackagesByType('library')); self::assertSame($names, \Composer\InstalledVersions::getInstalledPackagesByType('library'));
} }
public function testGetInstallPath(): void public function testGetInstallPath(): void
{ {
$this->assertSame(realpath($this->root), realpath(\Composer\InstalledVersions::getInstallPath('__root__'))); self::assertSame(realpath($this->root), realpath(\Composer\InstalledVersions::getInstallPath('__root__')));
$this->assertSame('/foo/bar/vendor/c/c', \Composer\InstalledVersions::getInstallPath('c/c')); self::assertSame('/foo/bar/vendor/c/c', \Composer\InstalledVersions::getInstallPath('c/c'));
$this->assertNull(\Composer\InstalledVersions::getInstallPath('foo/impl')); self::assertNull(\Composer\InstalledVersions::getInstallPath('foo/impl'));
} }
} }

View File

@ -82,8 +82,8 @@ class BinaryInstallerTest extends TestCase
$proc = new ProcessExecutor(); $proc = new ProcessExecutor();
$proc->execute($this->binDir.'/binary arg', $output); $proc->execute($this->binDir.'/binary arg', $output);
$this->assertEquals('', $proc->getErrorOutput()); self::assertEquals('', $proc->getErrorOutput());
$this->assertEquals('success arg', $output); self::assertEquals('success arg', $output);
} }
public static function executableBinaryProvider(): array public static function executableBinaryProvider(): array

View File

@ -57,7 +57,7 @@ class InstallationManagerTest extends TestCase
$manager = new InstallationManager($this->loop, $this->io); $manager = new InstallationManager($this->loop, $this->io);
$manager->addInstaller($installer); $manager->addInstaller($installer);
$this->assertSame($installer, $manager->getInstaller('vendor')); self::assertSame($installer, $manager->getInstaller('vendor'));
self::expectException('InvalidArgumentException'); self::expectException('InvalidArgumentException');
$manager->getInstaller('unregistered'); $manager->getInstaller('unregistered');
@ -86,11 +86,11 @@ class InstallationManagerTest extends TestCase
$manager = new InstallationManager($this->loop, $this->io); $manager = new InstallationManager($this->loop, $this->io);
$manager->addInstaller($installer); $manager->addInstaller($installer);
$this->assertSame($installer, $manager->getInstaller('vendor')); self::assertSame($installer, $manager->getInstaller('vendor'));
$manager->addInstaller($installer2); $manager->addInstaller($installer2);
$this->assertSame($installer2, $manager->getInstaller('vendor')); self::assertSame($installer2, $manager->getInstaller('vendor'));
$manager->removeInstaller($installer2); $manager->removeInstaller($installer2);
$this->assertSame($installer, $manager->getInstaller('vendor')); self::assertSame($installer, $manager->getInstaller('vendor'));
} }
public function testExecute(): void public function testExecute(): void

View File

@ -24,11 +24,9 @@ class InstallerEventTest extends TestCase
$transaction = $this->getMockBuilder('Composer\DependencyResolver\LockTransaction')->disableOriginalConstructor()->getMock(); $transaction = $this->getMockBuilder('Composer\DependencyResolver\LockTransaction')->disableOriginalConstructor()->getMock();
$event = new InstallerEvent('EVENT_NAME', $composer, $io, true, true, $transaction); $event = new InstallerEvent('EVENT_NAME', $composer, $io, true, true, $transaction);
$this->assertSame('EVENT_NAME', $event->getName()); self::assertSame('EVENT_NAME', $event->getName());
$this->assertInstanceOf('Composer\Composer', $event->getComposer()); self::assertTrue($event->isDevMode());
$this->assertInstanceOf('Composer\IO\IOInterface', $event->getIO()); self::assertTrue($event->isExecutingOperations());
$this->assertTrue($event->isDevMode()); self::assertInstanceOf('Composer\DependencyResolver\Transaction', $event->getTransaction());
$this->assertTrue($event->isExecutingOperations());
$this->assertInstanceOf('Composer\DependencyResolver\Transaction', $event->getTransaction());
} }
} }

View File

@ -108,7 +108,7 @@ class LibraryInstallerTest extends TestCase
$this->fs->removeDirectory($this->vendorDir); $this->fs->removeDirectory($this->vendorDir);
new LibraryInstaller($this->io, $this->composer); new LibraryInstaller($this->io, $this->composer);
$this->assertFileDoesNotExist($this->vendorDir); self::assertFileDoesNotExist($this->vendorDir);
} }
public function testInstallerCreationShouldNotCreateBinDirectory(): void public function testInstallerCreationShouldNotCreateBinDirectory(): void
@ -116,7 +116,7 @@ class LibraryInstallerTest extends TestCase
$this->fs->removeDirectory($this->binDir); $this->fs->removeDirectory($this->binDir);
new LibraryInstaller($this->io, $this->composer); new LibraryInstaller($this->io, $this->composer);
$this->assertFileDoesNotExist($this->binDir); self::assertFileDoesNotExist($this->binDir);
} }
public function testIsInstalled(): void public function testIsInstalled(): void
@ -125,18 +125,18 @@ class LibraryInstallerTest extends TestCase
$package = self::getPackage('test/pkg', '1.0.0'); $package = self::getPackage('test/pkg', '1.0.0');
$repository = new InstalledArrayRepository(); $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 // package being in repo is not enough to be installed
$repository->addPackage($package); $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 // package being in repo and vendor/pkg/foo dir present means it is seen as installed
self::ensureDirectoryExistsAndClear($this->vendorDir.'/'.$package->getPrettyName()); self::ensureDirectoryExistsAndClear($this->vendorDir.'/'.$package->getPrettyName());
$this->assertTrue($library->isInstalled($repository, $package)); self::assertTrue($library->isInstalled($repository, $package));
$repository->removePackage($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); ->with($package);
$library->install($this->repository, $package); $library->install($this->repository, $package);
$this->assertFileExists($this->vendorDir, 'Vendor dir should be created'); self::assertFileExists($this->vendorDir, 'Vendor dir should be created');
$this->assertFileExists($this->binDir, 'Bin 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 = new LibraryInstaller($this->io, $this->composer, 'library', $filesystem);
$library->update($this->repository, $initial, $target); $library->update($this->repository, $initial, $target);
$this->assertFileExists($this->vendorDir, 'Vendor dir should be created'); self::assertFileExists($this->vendorDir, 'Vendor dir should be created');
$this->assertFileExists($this->binDir, 'Bin dir should be created'); self::assertFileExists($this->binDir, 'Bin dir should be created');
self::expectException('InvalidArgumentException'); self::expectException('InvalidArgumentException');
@ -248,7 +248,7 @@ class LibraryInstallerTest extends TestCase
$library = new LibraryInstaller($this->io, $this->composer); $library = new LibraryInstaller($this->io, $this->composer);
$package = self::getPackage('Vendor/Pkg', '1.0.0'); $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 public function testGetInstallPathWithTargetDir(): void
@ -257,7 +257,7 @@ class LibraryInstallerTest extends TestCase
$package = self::getPackage('Foo/Bar', '1.0.0'); $package = self::getPackage('Foo/Bar', '1.0.0');
$package->setTargetDir('Some/Namespace'); $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));
} }
/** /**

View File

@ -56,7 +56,7 @@ class SuggestedPackagesReporterTest extends TestCase
*/ */
public function testGetPackagesEmptyByDefault(): void 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['target'],
$suggestedPackage['reason'] $suggestedPackage['reason']
); );
$this->assertSame( self::assertSame(
[$suggestedPackage], [$suggestedPackage],
$this->suggestedPackagesReporter->getPackages() $this->suggestedPackagesReporter->getPackages()
); );
@ -99,7 +99,7 @@ class SuggestedPackagesReporterTest extends TestCase
$suggestedPackageB['target'], $suggestedPackageB['target'],
$suggestedPackageB['reason'] $suggestedPackageB['reason']
); );
$this->assertSame( self::assertSame(
[$suggestedPackageA, $suggestedPackageB], [$suggestedPackageA, $suggestedPackageB],
$this->suggestedPackagesReporter->getPackages() $this->suggestedPackagesReporter->getPackages()
); );
@ -122,7 +122,7 @@ class SuggestedPackagesReporterTest extends TestCase
->will($this->returnValue('package-pretty-name')); ->will($this->returnValue('package-pretty-name'));
$this->suggestedPackagesReporter->addSuggestionsFromPackage($package); $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
$this->assertSame([ self::assertSame([
[ [
'source' => 'package-pretty-name', 'source' => 'package-pretty-name',
'target' => 'target-a', 'target' => 'target-a',

View File

@ -138,20 +138,20 @@ class InstallerTest extends TestCase
$result = $installer->run(); $result = $installer->run();
$output = str_replace("\r", '', $io->getOutput()); $output = str_replace("\r", '', $io->getOutput());
$this->assertEquals(0, $result, $output); self::assertEquals(0, $result, $output);
$expectedInstalled = $options['install'] ?? []; $expectedInstalled = $options['install'] ?? [];
$expectedUpdated = $options['update'] ?? []; $expectedUpdated = $options['update'] ?? [];
$expectedUninstalled = $options['uninstall'] ?? []; $expectedUninstalled = $options['uninstall'] ?? [];
$installed = $installationManager->getInstalledPackages(); $installed = $installationManager->getInstalledPackages();
$this->assertEquals($this->makePackagesComparable($expectedInstalled), $this->makePackagesComparable($installed)); self::assertEquals($this->makePackagesComparable($expectedInstalled), $this->makePackagesComparable($installed));
$updated = $installationManager->getUpdatedPackages(); $updated = $installationManager->getUpdatedPackages();
$this->assertSame($expectedUpdated, $updated); self::assertSame($expectedUpdated, $updated);
$uninstalled = $installationManager->getUninstalledPackages(); $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()); $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)) { if ($expectLock && isset($actualLock)) {
unset($actualLock['hash'], $actualLock['content-hash'], $actualLock['_readme'], $actualLock['plugin-api-version']); unset($actualLock['hash'], $actualLock['content-hash'], $actualLock['_readme'], $actualLock['plugin-api-version']);
$this->assertEquals($expectLock, $actualLock); self::assertEquals($expectLock, $actualLock);
} }
if ($expectInstalled !== null) { if ($expectInstalled !== null) {
@ -461,18 +461,18 @@ class InstallerTest extends TestCase
return strcmp($a['name'], $b['name']); return strcmp($a['name'], $b['name']);
}); });
$this->assertSame($expectInstalled, $actualInstalled); self::assertSame($expectInstalled, $actualInstalled);
} }
/** @var InstallationManagerMock $installationManager */ /** @var InstallationManagerMock $installationManager */
$installationManager = $composer->getInstallationManager(); $installationManager = $composer->getInstallationManager();
$this->assertSame(rtrim($expect), implode("\n", $installationManager->getTrace())); self::assertSame(rtrim($expect), implode("\n", $installationManager->getTrace()));
if ($expectOutput) { if ($expectOutput) {
$output = Preg::replace('{^ - .*?\.ini$}m', '__inilist__', $output); $output = Preg::replace('{^ - .*?\.ini$}m', '__inilist__', $output);
$output = Preg::replace('{(__inilist__\r?\n)+}', "__inilist__\n", $output); $output = Preg::replace('{(__inilist__\r?\n)+}', "__inilist__\n", $output);
$this->assertStringMatchesFormat(rtrim($expectOutput), rtrim($output)); self::assertStringMatchesFormat(rtrim($expectOutput), rtrim($output));
} }
} }

View File

@ -33,21 +33,21 @@ class ComposerSchemaTest extends TestCase
]; ];
$json = '{"name": "vendor/-pack__age", "description": "description"}'; $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"}'; $json = '{"name": "Vendor/Package", "description": "description"}';
$this->assertEquals($expectedError, $this->check($json)); self::assertEquals($expectedError, $this->check($json));
} }
public function testOptionalAbandonedProperty(): void public function testOptionalAbandonedProperty(): void
{ {
$json = '{"name": "vendor/package", "description": "description", "abandoned": true}'; $json = '{"name": "vendor/package", "description": "description", "abandoned": true}';
$this->assertTrue($this->check($json)); self::assertTrue($this->check($json));
} }
public function testRequireTypes(): void public function testRequireTypes(): void
{ {
$json = '{"name": "vendor/package", "description": "description", "require": {"a": ["b"]} }'; $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'], ['property' => 'require.a', 'message' => 'Array value found, but a string is required', 'constraint' => 'type'],
], $this->check($json)); ], $this->check($json));
} }
@ -64,31 +64,31 @@ class ComposerSchemaTest extends TestCase
]; ];
$json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "" }'; $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" }'; $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" }'; $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" }'; $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" }'; $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" }'; $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" }'; $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" }'; $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" }'; $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "stable" }';
$this->assertTrue($this->check($json), 'stable'); self::assertTrue($this->check($json), 'stable');
} }
/** /**

View File

@ -110,15 +110,15 @@ class JsonFileTest extends TestCase
$json->validateSchema(); $json->validateSchema();
$this->fail('Expected exception to be thrown (strict)'); $this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage()); self::assertEquals($expectedMessage, $e->getMessage());
$this->assertContains($expectedError, $e->getErrors()); self::assertContains($expectedError, $e->getErrors());
} }
try { try {
$json->validateSchema(JsonFile::LAX_SCHEMA); $json->validateSchema(JsonFile::LAX_SCHEMA);
$this->fail('Expected exception to be thrown (lax)'); $this->fail('Expected exception to be thrown (lax)');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage()); self::assertEquals($expectedMessage, $e->getMessage());
$this->assertContains($expectedError, $e->getErrors()); self::assertContains($expectedError, $e->getErrors());
} }
unlink($file); unlink($file);
} }
@ -132,8 +132,8 @@ class JsonFileTest extends TestCase
$json->validateSchema(); $json->validateSchema();
$this->fail('Expected exception to be thrown (strict)'); $this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals(sprintf('"%s" does not match the expected JSON schema', $file), $e->getMessage()); self::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(['The property foo is not defined and the definition does not allow additional properties'], $e->getErrors());
} }
$json->validateSchema(JsonFile::LAX_SCHEMA); $json->validateSchema(JsonFile::LAX_SCHEMA);
unlink($file); unlink($file);
@ -151,10 +151,10 @@ class JsonFileTest extends TestCase
$json->validateSchema(); $json->validateSchema();
$this->fail('Expected exception to be thrown (strict)'); $this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage()); self::assertEquals($expectedMessage, $e->getMessage());
$errors = $e->getErrors(); $errors = $e->getErrors();
$this->assertContains('name : The property name is required', $errors); self::assertContains('name : The property name is required', $errors);
$this->assertContains('description : The property description is required', $errors); self::assertContains('description : The property description is required', $errors);
} }
$json->validateSchema(JsonFile::LAX_SCHEMA); $json->validateSchema(JsonFile::LAX_SCHEMA);
@ -163,8 +163,8 @@ class JsonFileTest extends TestCase
$json->validateSchema(); $json->validateSchema();
$this->fail('Expected exception to be thrown (strict)'); $this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage()); self::assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals(['description : The property description is required'], $e->getErrors()); self::assertEquals(['description : The property description is required'], $e->getErrors());
} }
$json->validateSchema(JsonFile::LAX_SCHEMA); $json->validateSchema(JsonFile::LAX_SCHEMA);
@ -173,8 +173,8 @@ class JsonFileTest extends TestCase
$json->validateSchema(); $json->validateSchema();
$this->fail('Expected exception to be thrown (strict)'); $this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage()); self::assertEquals($expectedMessage, $e->getMessage());
$this->assertEquals(['name : The property name is required'], $e->getErrors()); self::assertEquals(['name : The property name is required'], $e->getErrors());
} }
$json->validateSchema(JsonFile::LAX_SCHEMA); $json->validateSchema(JsonFile::LAX_SCHEMA);
@ -183,10 +183,10 @@ class JsonFileTest extends TestCase
$json->validateSchema(); $json->validateSchema();
$this->fail('Expected exception to be thrown (strict)'); $this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage()); self::assertEquals($expectedMessage, $e->getMessage());
$errors = $e->getErrors(); $errors = $e->getErrors();
$this->assertContains('name : The property name is required', $errors); self::assertContains('name : The property name is required', $errors);
$this->assertContains('description : The property description is required', $errors); self::assertContains('description : The property description is required', $errors);
} }
$json->validateSchema(JsonFile::LAX_SCHEMA); $json->validateSchema(JsonFile::LAX_SCHEMA);
@ -195,10 +195,10 @@ class JsonFileTest extends TestCase
$json->validateSchema(); $json->validateSchema();
$this->fail('Expected exception to be thrown (strict)'); $this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage()); self::assertEquals($expectedMessage, $e->getMessage());
$errors = $e->getErrors(); $errors = $e->getErrors();
$this->assertContains('name : The property name is required', $errors); self::assertContains('name : The property name is required', $errors);
$this->assertContains('description : The property description is required', $errors); self::assertContains('description : The property description is required', $errors);
} }
$json->validateSchema(JsonFile::LAX_SCHEMA); $json->validateSchema(JsonFile::LAX_SCHEMA);
@ -252,8 +252,8 @@ class JsonFileTest extends TestCase
JsonFile::validateJsonSchema('COMPOSER_AUTH', $json, JsonFile::AUTH_SCHEMA); JsonFile::validateJsonSchema('COMPOSER_AUTH', $json, JsonFile::AUTH_SCHEMA);
$this->fail('Expected exception to be thrown'); $this->fail('Expected exception to be thrown');
} catch (JsonValidationException $e) { } catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage()); self::assertEquals($expectedMessage, $e->getMessage());
$this->assertSame([$expectedError], $e->getErrors()); self::assertSame([$expectedError], $e->getErrors());
} }
} }
@ -282,7 +282,7 @@ class JsonFileTest extends TestCase
$json = '{ $json = '{
"name": "composer/composer" "name": "composer/composer"
}'; }';
$this->assertJsonFormat($json, $data); self::assertJsonFormat($json, $data);
} }
public function testTrailingBackslash(): void public function testTrailingBackslash(): void
@ -291,7 +291,7 @@ class JsonFileTest extends TestCase
$json = '{ $json = '{
"Metadata\\\\": "src/" "Metadata\\\\": "src/"
}'; }';
$this->assertJsonFormat($json, $data); self::assertJsonFormat($json, $data);
} }
public function testFormatEmptyArray(): void public function testFormatEmptyArray(): void
@ -301,7 +301,7 @@ class JsonFileTest extends TestCase
"test": [], "test": [],
"test2": {} "test2": {}
}'; }';
$this->assertJsonFormat($json, $data); self::assertJsonFormat($json, $data);
} }
public function testEscape(): void public function testEscape(): void
@ -311,7 +311,7 @@ class JsonFileTest extends TestCase
"Metadata\\\\\\"": "src/" "Metadata\\\\\\"": "src/"
}'; }';
$this->assertJsonFormat($json, $data); self::assertJsonFormat($json, $data);
} }
public function testUnicode(): void public function testUnicode(): void
@ -321,35 +321,35 @@ class JsonFileTest extends TestCase
"Žluťoučký \" kůň": "úpěl ďábelské ódy za €" "Žluťoučký \" kůň": "úpěl ďábelské ódy za €"
}'; }';
$this->assertJsonFormat($json, $data); self::assertJsonFormat($json, $data);
} }
public function testOnlyUnicode(): void public function testOnlyUnicode(): void
{ {
$data = "\\"; $data = "\\";
$this->assertJsonFormat('"\\\\\\/ƌ"', $data, JSON_UNESCAPED_UNICODE); self::assertJsonFormat('"\\\\\\/ƌ"', $data, JSON_UNESCAPED_UNICODE);
} }
public function testEscapedSlashes(): void public function testEscapedSlashes(): void
{ {
$data = "\\/foo"; $data = "\\/foo";
$this->assertJsonFormat('"\\\\\\/foo"', $data, 0); self::assertJsonFormat('"\\\\\\/foo"', $data, 0);
} }
public function testEscapedBackslashes(): void public function testEscapedBackslashes(): void
{ {
$data = "a\\b"; $data = "a\\b";
$this->assertJsonFormat('"a\\\\b"', $data, 0); self::assertJsonFormat('"a\\\\b"', $data, 0);
} }
public function testEscapedUnicode(): void public function testEscapedUnicode(): void
{ {
$data = "ƌ"; $data = "ƌ";
$this->assertJsonFormat('"\\u018c"', $data, 0); self::assertJsonFormat('"\\u018c"', $data, 0);
} }
public function testDoubleEscapedUnicode(): void public function testDoubleEscapedUnicode(): void
@ -361,7 +361,7 @@ class JsonFileTest extends TestCase
$decodedData = json_decode($doubleEncodedData, true); $decodedData = json_decode($doubleEncodedData, true);
$doubleData = json_decode($decodedData['t'], true); $doubleData = json_decode($decodedData['t'], true);
$this->assertEquals($data, $doubleData); self::assertEquals($data, $doubleData);
} }
public function testPreserveIndentationAfterRead(): void public function testPreserveIndentationAfterRead(): void
@ -393,7 +393,7 @@ class JsonFileTest extends TestCase
$result = JsonFile::parseJson($json); $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))); $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) { } 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); $json = str_replace("\r", '', $json);
if (null === $options) { if (null === $options) {
$this->assertEquals($json, $file->encode($data)); self::assertEquals($json, $file->encode($data));
} else { } else {
$this->assertEquals($json, $file->encode($data, $options)); self::assertEquals($json, $file->encode($data, $options));
} }
} }
} }

View File

@ -30,7 +30,7 @@ class JsonFormatterTest extends TestCase
$data = '"' . $backslash . $backslash . $backslash . 'u0119"'; $data = '"' . $backslash . $backslash . $backslash . 'u0119"';
$expected = '"' . $backslash . $backslash . 'ę"'; $expected = '"' . $backslash . $backslash . 'ę"';
/** @phpstan-ignore staticMethod.dynamicCall, staticMethod.deprecatedClass */ /** @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"'; $escaped = '"\ud83d\ude00"';
/** @phpstan-ignore staticMethod.dynamicCall, staticMethod.deprecatedClass */ /** @phpstan-ignore staticMethod.dynamicCall, staticMethod.deprecatedClass */
$this->assertEquals($escaped, JsonFormatter::format($escaped, true, true)); self::assertEquals($escaped, JsonFormatter::format($escaped, true, true));
} }
} }

View File

@ -12,6 +12,7 @@
namespace Composer\Test\Json; namespace Composer\Test\Json;
use Composer\Json\JsonFile;
use Composer\Json\JsonManipulator; use Composer\Json\JsonManipulator;
use Composer\Test\TestCase; 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 public function testAddLink(string $json, string $type, string $package, string $constraint, string $expected): void
{ {
$manipulator = new JsonManipulator($json); $manipulator = new JsonManipulator($json);
$this->assertTrue($manipulator->addLink($type, $package, $constraint)); self::assertTrue($manipulator->addLink($type, $package, $constraint));
$this->assertEquals($expected, $manipulator->getContents()); self::assertEquals($expected, $manipulator->getContents());
} }
public static function linkProvider(): array 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 public function testAddLinkAndSortPackages(string $json, string $type, string $package, string $constraint, bool $sortPackages, string $expected): void
{ {
$manipulator = new JsonManipulator($json); $manipulator = new JsonManipulator($json);
$this->assertTrue($manipulator->addLink($type, $package, $constraint, $sortPackages)); self::assertTrue($manipulator->addLink($type, $package, $constraint, $sortPackages));
$this->assertEquals($expected, $manipulator->getContents()); self::assertEquals($expected, $manipulator->getContents());
} }
public static function providerAddLinkAndSortPackages(): array public static function providerAddLinkAndSortPackages(): array
@ -1374,9 +1375,9 @@ class JsonManipulatorTest extends TestCase
{ {
$manipulator = new JsonManipulator($json); $manipulator = new JsonManipulator($json);
$this->assertEquals($expected, $manipulator->removeSubNode('repositories', $name)); self::assertEquals($expected, $manipulator->removeSubNode('repositories', $name));
if (null !== $expectedContent) { 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')); self::assertTrue($manipulator->removeSubNode('require', 'package/c'));
$this->assertTrue($manipulator->removeSubNode('require-dev', 'package/d')); self::assertTrue($manipulator->removeSubNode('require-dev', 'package/d'));
$this->assertEquals('{ self::assertEquals('{
"repositories": [ "repositories": [
{ {
"package": { "package": {
@ -1727,8 +1728,8 @@ class JsonManipulatorTest extends TestCase
"test": {"0": "foo"} "test": {"0": "foo"}
}'); }');
$this->assertTrue($manipulator->removeSubNode('test', '0')); self::assertTrue($manipulator->removeSubNode('test', '0'));
$this->assertEquals('{ self::assertEquals('{
"test": { "test": {
} }
} }
@ -1743,8 +1744,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->removeConfigSetting('preferred-install.foo/*')); self::assertTrue($manipulator->removeConfigSetting('preferred-install.foo/*'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"preferred-install": { "preferred-install": {
} }
@ -1777,9 +1778,9 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addSubNode('require', 'package/c', '*')); self::assertTrue($manipulator->addSubNode('require', 'package/c', '*'));
$this->assertTrue($manipulator->addSubNode('require-dev', 'package/e', '*')); self::assertTrue($manipulator->addSubNode('require-dev', 'package/e', '*'));
$this->assertEquals('{ self::assertEquals('{
"repositories": [ "repositories": [
{ {
"package": { "package": {
@ -1825,8 +1826,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addProperty('extra.foo-bar', true)); self::assertTrue($manipulator->addProperty('extra.foo-bar', true));
$this->assertEquals('{ self::assertEquals('{
"repositories": [ "repositories": [
{ {
"type": "package", "type": "package",
@ -1867,8 +1868,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('preferred-install.my-organization/stable-package', 'dist')); self::assertTrue($manipulator->addConfigSetting('preferred-install.my-organization/stable-package', 'dist'));
$this->assertEquals('{ self::assertEquals('{
"repositories": [ "repositories": [
{ {
"type": "package", "type": "package",
@ -1911,8 +1912,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addProperty('suggest.new-package', 'new-description')); self::assertTrue($manipulator->addProperty('suggest.new-package', 'new-description'));
$this->assertEquals('{ self::assertEquals('{
"repositories": [ "repositories": [
{ {
"type": "package", "type": "package",
@ -1939,8 +1940,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addRepository('bar', ['type' => 'composer'])); self::assertTrue($manipulator->addRepository('bar', ['type' => 'composer']));
$this->assertEquals('{ self::assertEquals('{
"repositories": { "repositories": {
"bar": { "bar": {
"type": "composer" "type": "composer"
@ -1956,8 +1957,8 @@ class JsonManipulatorTest extends TestCase
\t\"a\": \"b\" \t\"a\": \"b\"
}"); }");
$this->assertTrue($manipulator->addRepository('bar2', ['type' => 'composer'])); self::assertTrue($manipulator->addRepository('bar2', ['type' => 'composer']));
$this->assertEquals("{ self::assertEquals("{
\t\"a\": \"b\", \t\"a\": \"b\",
\t\"repositories\": { \t\"repositories\": {
\t\t\"bar2\": { \t\t\"bar2\": {
@ -1979,8 +1980,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addRepository('bar', ['type' => 'composer'], true)); self::assertTrue($manipulator->addRepository('bar', ['type' => 'composer'], true));
$this->assertEquals('{ self::assertEquals('{
"repositories": { "repositories": {
"foo": { "foo": {
"type": "vcs", "type": "vcs",
@ -2005,8 +2006,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addRepository('bar', ['type' => 'composer'], false)); self::assertTrue($manipulator->addRepository('bar', ['type' => 'composer'], false));
$this->assertEquals('{ self::assertEquals('{
"repositories": { "repositories": {
"bar": { "bar": {
"type": "composer" "type": "composer"
@ -2031,8 +2032,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addRepository('baz', ['type' => 'composer'])); self::assertTrue($manipulator->addRepository('baz', ['type' => 'composer']));
$this->assertEquals('{ self::assertEquals('{
"repositories": { "repositories": {
"baz": { "baz": {
"type": "composer" "type": "composer"
@ -2049,9 +2050,9 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('test', 'a\b')); self::assertTrue($manipulator->addConfigSetting('test', 'a\b'));
$this->assertTrue($manipulator->addConfigSetting('test2', "a\nb\fa")); self::assertTrue($manipulator->addConfigSetting('test2', "a\nb\fa"));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"test": "a\\\\b", "test": "a\\\\b",
"test2": "a\nb\fa" "test2": "a\nb\fa"
@ -2065,8 +2066,8 @@ class JsonManipulatorTest extends TestCase
$manipulator = new JsonManipulator('{ $manipulator = new JsonManipulator('{
}'); }');
$this->assertTrue($manipulator->addConfigSetting('foo.bar', 'baz')); self::assertTrue($manipulator->addConfigSetting('foo.bar', 'baz'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"foo": { "foo": {
"bar": "baz" "bar": "baz"
@ -2084,8 +2085,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('bar', 'baz')); self::assertTrue($manipulator->addConfigSetting('bar', 'baz'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"foo": "bar", "foo": "bar",
"bar": "baz" "bar": "baz"
@ -2103,8 +2104,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('foo', 'zomg')); self::assertTrue($manipulator->addConfigSetting('foo', 'zomg'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"foo": "zomg", "foo": "zomg",
"bar": "baz" "bar": "baz"
@ -2121,8 +2122,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('foo', 50)); self::assertTrue($manipulator->addConfigSetting('foo', 50));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"foo": 50 "foo": 50
} }
@ -2141,8 +2142,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('github-protocols', ['https', 'http'])); self::assertTrue($manipulator->addConfigSetting('github-protocols', ['https', 'http']));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"github-oauth": { "github-oauth": {
"github.com": "foo" "github.com": "foo"
@ -2152,8 +2153,8 @@ class JsonManipulatorTest extends TestCase
} }
', $manipulator->getContents()); ', $manipulator->getContents());
$this->assertTrue($manipulator->addConfigSetting('github-oauth', ['github.com' => 'bar', 'alt.example.org' => 'baz'])); self::assertTrue($manipulator->addConfigSetting('github-oauth', ['github.com' => 'bar', 'alt.example.org' => 'baz']));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"github-oauth": { "github-oauth": {
"github.com": "bar", "github.com": "bar",
@ -2172,8 +2173,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); self::assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"github-oauth": { "github-oauth": {
"bar": "baz" "bar": "baz"
@ -2193,10 +2194,10 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); self::assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz'));
$this->assertTrue($manipulator->addConfigSetting('github-oauth2.a.bar', 'baz2')); self::assertTrue($manipulator->addConfigSetting('github-oauth2.a.bar', 'baz2'));
$this->assertTrue($manipulator->addConfigSetting('github-oauth3.b', 'c')); self::assertTrue($manipulator->addConfigSetting('github-oauth3.b', 'c'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"github-oauth": { "github-oauth": {
"bar": "baz" "bar": "baz"
@ -2222,8 +2223,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz')); self::assertTrue($manipulator->addConfigSetting('github-oauth.bar', 'baz'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"github-oauth": { "github-oauth": {
"github.com": "foo", "github.com": "foo",
@ -2242,8 +2243,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addSubNode('github-oauth', 'bar', 'baz')); self::assertTrue($manipulator->addSubNode('github-oauth', 'bar', 'baz'));
$this->assertEquals('{ self::assertEquals('{
"github-oauth": { "github-oauth": {
"github.com": "foo", "github.com": "foo",
"bar": "baz" "bar": "baz"
@ -2263,8 +2264,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->removeConfigSetting('github-oauth.bar')); self::assertTrue($manipulator->removeConfigSetting('github-oauth.bar'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"github-oauth": { "github-oauth": {
"github.com": "foo" "github.com": "foo"
@ -2286,8 +2287,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->removeConfigSetting('github-oauth.bar')); self::assertTrue($manipulator->removeConfigSetting('github-oauth.bar'));
$this->assertEquals('{ self::assertEquals('{
"config": { "config": {
"foo": "bar", "foo": "bar",
"github-oauth": { "github-oauth": {
@ -2304,8 +2305,8 @@ class JsonManipulatorTest extends TestCase
"foo": "bar" "foo": "bar"
}'); }');
$this->assertTrue($manipulator->addMainKey('bar', 'baz')); self::assertTrue($manipulator->addMainKey('bar', 'baz'));
$this->assertEquals('{ self::assertEquals('{
"foo": "bar", "foo": "bar",
"bar": "baz" "bar": "baz"
} }
@ -2318,8 +2319,8 @@ class JsonManipulatorTest extends TestCase
"foo": "bar" "foo": "bar"
}'); }');
$this->assertTrue($manipulator->addMainKey('bar', '$1baz')); self::assertTrue($manipulator->addMainKey('bar', '$1baz'));
$this->assertEquals('{ self::assertEquals('{
"foo": "bar", "foo": "bar",
"bar": "$1baz" "bar": "$1baz"
} }
@ -2330,8 +2331,8 @@ class JsonManipulatorTest extends TestCase
{ {
$manipulator = new JsonManipulator('{}'); $manipulator = new JsonManipulator('{}');
$this->assertTrue($manipulator->addMainKey('foo', '$1bar')); self::assertTrue($manipulator->addMainKey('foo', '$1bar'));
$this->assertEquals('{ self::assertEquals('{
"foo": "$1bar" "foo": "$1bar"
} }
', $manipulator->getContents()); ', $manipulator->getContents());
@ -2343,8 +2344,8 @@ class JsonManipulatorTest extends TestCase
"foo": "bar" "foo": "bar"
}'); }');
$this->assertTrue($manipulator->addMainKey('foo', 'baz')); self::assertTrue($manipulator->addMainKey('foo', 'baz'));
$this->assertEquals('{ self::assertEquals('{
"foo": "baz" "foo": "baz"
} }
', $manipulator->getContents()); ', $manipulator->getContents());
@ -2361,9 +2362,9 @@ class JsonManipulatorTest extends TestCase
"baz": "bar" "baz": "bar"
}'); }');
$this->assertTrue($manipulator->addMainKey('foo', 'baz')); self::assertTrue($manipulator->addMainKey('foo', 'baz'));
$this->assertTrue($manipulator->addMainKey('baz', 'quux')); self::assertTrue($manipulator->addMainKey('baz', 'quux'));
$this->assertEquals('{ self::assertEquals('{
"a": { "a": {
"foo": "bar", "foo": "bar",
"baz": "qux" "baz": "qux"
@ -2385,8 +2386,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addMainKey('require-dev', ['foo' => 'qux'])); self::assertTrue($manipulator->addMainKey('require-dev', ['foo' => 'qux']));
$this->assertEquals('{ self::assertEquals('{
"require": { "require": {
"php": "5.*" "php": "5.*"
}, },
@ -2403,8 +2404,8 @@ class JsonManipulatorTest extends TestCase
"foo": "bar" "foo": "bar"
}'); }');
$this->assertTrue($manipulator->addMainKey('foo', '$1bar')); self::assertTrue($manipulator->addMainKey('foo', '$1bar'));
$this->assertEquals('{ self::assertEquals('{
"foo": "$1bar" "foo": "$1bar"
} }
', $manipulator->getContents()); ', $manipulator->getContents());
@ -2436,8 +2437,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->removeMainKey('repositories')); self::assertTrue($manipulator->removeMainKey('repositories'));
$this->assertEquals('{ self::assertEquals('{
"require": { "require": {
"package/a": "*", "package/a": "*",
"package/b": "*", "package/b": "*",
@ -2450,8 +2451,8 @@ class JsonManipulatorTest extends TestCase
} }
', $manipulator->getContents()); ', $manipulator->getContents());
$this->assertTrue($manipulator->removeMainKey('foo')); self::assertTrue($manipulator->removeMainKey('foo'));
$this->assertEquals('{ self::assertEquals('{
"require": { "require": {
"package/a": "*", "package/a": "*",
"package/b": "*", "package/b": "*",
@ -2463,9 +2464,9 @@ class JsonManipulatorTest extends TestCase
} }
', $manipulator->getContents()); ', $manipulator->getContents());
$this->assertTrue($manipulator->removeMainKey('require')); self::assertTrue($manipulator->removeMainKey('require'));
$this->assertTrue($manipulator->removeMainKey('require-dev')); self::assertTrue($manipulator->removeMainKey('require-dev'));
$this->assertEquals('{ self::assertEquals('{
} }
', $manipulator->getContents()); ', $manipulator->getContents());
} }
@ -2485,8 +2486,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->removeMainKeyIfEmpty('repositories')); self::assertTrue($manipulator->removeMainKeyIfEmpty('repositories'));
$this->assertEquals('{ self::assertEquals('{
"require": { "require": {
"package/a": "*", "package/a": "*",
"package/b": "*", "package/b": "*",
@ -2498,10 +2499,10 @@ class JsonManipulatorTest extends TestCase
} }
', $manipulator->getContents()); ', $manipulator->getContents());
$this->assertTrue($manipulator->removeMainKeyIfEmpty('foo')); self::assertTrue($manipulator->removeMainKeyIfEmpty('foo'));
$this->assertTrue($manipulator->removeMainKeyIfEmpty('require')); self::assertTrue($manipulator->removeMainKeyIfEmpty('require'));
$this->assertTrue($manipulator->removeMainKeyIfEmpty('require-dev')); self::assertTrue($manipulator->removeMainKeyIfEmpty('require-dev'));
$this->assertEquals('{ self::assertEquals('{
"require": { "require": {
"package/a": "*", "package/a": "*",
"package/b": "*", "package/b": "*",
@ -2521,11 +2522,11 @@ class JsonManipulatorTest extends TestCase
$manipulator->removeMainKey('bar'); $manipulator->removeMainKey('bar');
$expected = json_encode([ $expected = JsonFile::encode([
'foo' => 9000, 'foo' => 9000,
]); ]);
$this->assertJsonStringEqualsJsonString($expected, $manipulator->getContents()); self::assertJsonStringEqualsJsonString($expected, $manipulator->getContents());
} }
public function testIndentDetection(): void public function testIndentDetection(): void
@ -2537,8 +2538,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addMainKey('require-dev', ['foo' => 'qux'])); self::assertTrue($manipulator->addMainKey('require-dev', ['foo' => 'qux']));
$this->assertEquals('{ self::assertEquals('{
"require": { "require": {
"php": "5.*" "php": "5.*"
@ -2558,9 +2559,9 @@ class JsonManipulatorTest extends TestCase
} }
} }
'); ');
$this->assertTrue($manipulator->addMainKey('homepage', 'http...')); self::assertTrue($manipulator->addMainKey('homepage', 'http...'));
$this->assertTrue($manipulator->addMainKey('license', 'mit')); self::assertTrue($manipulator->addMainKey('license', 'mit'));
$this->assertEquals('{ self::assertEquals('{
"require": { "require": {
"package/a": "*" "package/a": "*"
}, },
@ -2569,9 +2570,9 @@ class JsonManipulatorTest extends TestCase
} }
', $manipulator->getContents()); ', $manipulator->getContents());
$this->assertTrue($manipulator->removeMainKey('homepage')); self::assertTrue($manipulator->removeMainKey('homepage'));
$this->assertTrue($manipulator->removeMainKey('license')); self::assertTrue($manipulator->removeMainKey('license'));
$this->assertEquals('{ self::assertEquals('{
"require": { "require": {
"package/a": "*" "package/a": "*"
} }
@ -2588,8 +2589,8 @@ class JsonManipulatorTest extends TestCase
} }
}'); }');
$this->assertTrue($manipulator->addLink('require', 'foo/baz', '^1.0')); self::assertTrue($manipulator->addLink('require', 'foo/baz', '^1.0'));
$this->assertEquals('{ self::assertEquals('{
"description": "Some U\u00F1icode", "description": "Some U\u00F1icode",
"require": { "require": {
"foo/bar": "^1.0", "foo/bar": "^1.0",
@ -3251,8 +3252,8 @@ class JsonManipulatorTest extends TestCase
"prefer-stable": true "prefer-stable": true
}'); }');
$this->assertTrue($manipulator->addSubNode('config', 'platform-check', false)); self::assertTrue($manipulator->addSubNode('config', 'platform-check', false));
$this->assertEquals('{ self::assertEquals('{
"name": "leoloso/pop", "name": "leoloso/pop",
"require": { "require": {
"php": "^7.4|^8.0", "php": "^7.4|^8.0",

View File

@ -25,14 +25,14 @@ class JsonValidationExceptionTest extends TestCase
public function testGetErrors(string $message, array $errors, string $expectedMessage, array $expectedErrors): void public function testGetErrors(string $message, array $errors, string $expectedMessage, array $expectedErrors): void
{ {
$object = new JsonValidationException($message, $errors); $object = new JsonValidationException($message, $errors);
$this->assertSame($expectedMessage, $object->getMessage()); self::assertSame($expectedMessage, $object->getMessage());
$this->assertSame($expectedErrors, $object->getErrors()); self::assertSame($expectedErrors, $object->getErrors());
} }
public function testGetErrorsWhenNoErrorsProvided(): void public function testGetErrorsWhenNoErrorsProvided(): void
{ {
$object = new JsonValidationException('test message'); $object = new JsonValidationException('test message');
$this->assertEquals([], $object->getErrors()); self::assertEquals([], $object->getErrors());
} }
public static function errorProvider(): array public static function errorProvider(): array

View File

@ -116,7 +116,7 @@ class ArchivableFilesFinderTest extends TestCase
$this->finder = new ArchivableFilesFinder($this->sources, $excludes); $this->finder = new ArchivableFilesFinder($this->sources, $excludes);
$this->assertArchivableFiles([ self::assertArchivableFiles([
'/!important!.txt', '/!important!.txt',
'/!important_too!.txt', '/!important_too!.txt',
'/#weirdfile', '/#weirdfile',
@ -191,7 +191,7 @@ class ArchivableFilesFinderTest extends TestCase
$this->finder = new ArchivableFilesFinder($this->sources, []); $this->finder = new ArchivableFilesFinder($this->sources, []);
$this->assertArchivableFiles($this->getArchivedFiles( self::assertArchivableFiles($this->getArchivedFiles(
'git init && '. 'git init && '.
'git config user.email "you@example.com" && '. 'git config user.email "you@example.com" && '.
'git config user.name "Your Name" && '. 'git config user.name "Your Name" && '.
@ -212,7 +212,7 @@ class ArchivableFilesFinderTest extends TestCase
$this->finder = new ArchivableFilesFinder($this->sources, $excludes, true); $this->finder = new ArchivableFilesFinder($this->sources, $excludes, true);
$this->assertArchivableFiles([ self::assertArchivableFiles([
'/!important!.txt', '/!important!.txt',
'/!important_too!.txt', '/!important_too!.txt',
'/#weirdfile', '/#weirdfile',
@ -306,6 +306,6 @@ class ArchivableFilesFinderTest extends TestCase
{ {
$actualFiles = $this->getArchivableFiles(); $actualFiles = $this->getArchivableFiles();
$this->assertEquals($expectedFiles, $actualFiles); self::assertEquals($expectedFiles, $actualFiles);
} }
} }

View File

@ -69,10 +69,10 @@ class ArchiveManagerTest extends ArchiverTestCase
$this->manager->archive($package, 'tar', $this->targetDir); $this->manager->archive($package, 'tar', $this->targetDir);
$target = $this->getTargetName($package, 'tar'); $target = $this->getTargetName($package, 'tar');
$this->assertFileExists($target); self::assertFileExists($target);
$tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package); $tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package);
$this->assertFileDoesNotExist($tmppath); self::assertFileDoesNotExist($tmppath);
unlink($target); unlink($target);
} }
@ -91,10 +91,10 @@ class ArchiveManagerTest extends ArchiverTestCase
$target = $this->targetDir . '/' . $fileName . '.tar'; $target = $this->targetDir . '/' . $fileName . '.tar';
$this->assertFileExists($target); self::assertFileExists($target);
$tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package); $tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package);
$this->assertFileDoesNotExist($tmppath); self::assertFileDoesNotExist($tmppath);
unlink($target); unlink($target);
} }

View File

@ -26,7 +26,7 @@ class GitExcludeFilterTest extends TestCase
{ {
$filter = new GitExcludeFilter('/'); $filter = new GitExcludeFilter('/');
$this->assertEquals($expected, $filter->parseGitAttributesLine($ignore)); self::assertEquals($expected, $filter->parseGitAttributesLine($ignore));
} }
public static function providePatterns(): array public static function providePatterns(): array

View File

@ -27,7 +27,7 @@ class PharArchiverTest extends ArchiverTestCase
// Test archive // Test archive
$archiver = new PharArchiver(); $archiver = new PharArchiver();
$archiver->archive($package->getSourceUrl(), $target, 'tar', ['foo/bar', 'baz', '!/foo/bar/baz']); $archiver->archive($package->getSourceUrl(), $target, 'tar', ['foo/bar', 'baz', '!/foo/bar/baz']);
$this->assertFileExists($target); self::assertFileExists($target);
$this->filesystem->removeDirectory(dirname($target)); $this->filesystem->removeDirectory(dirname($target));
} }
@ -42,7 +42,7 @@ class PharArchiverTest extends ArchiverTestCase
// Test archive // Test archive
$archiver = new PharArchiver(); $archiver = new PharArchiver();
$archiver->archive($package->getSourceUrl(), $target, 'zip'); $archiver->archive($package->getSourceUrl(), $target, 'zip');
$this->assertFileExists($target); self::assertFileExists($target);
$this->filesystem->removeDirectory(dirname($target)); $this->filesystem->removeDirectory(dirname($target));
} }

View File

@ -54,7 +54,7 @@ class BasePackageTest extends TestCase
$package->expects($this->once())->method('getPrettyVersion')->will($this->returnValue('PrettyVersion')); $package->expects($this->once())->method('getPrettyVersion')->will($this->returnValue('PrettyVersion'));
$package->expects($this->any())->method('getSourceReference')->will($this->returnValue($sourceReference)); $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 public static function provideFormattedVersions(): array
@ -93,7 +93,7 @@ class BasePackageTest extends TestCase
{ {
$regexp = BasePackage::packageNamesToRegexp($packageNames, $wrap); $regexp = BasePackage::packageNamesToRegexp($packageNames, $wrap);
$this->assertSame($expectedRegexp, $regexp); self::assertSame($expectedRegexp, $regexp);
} }
/** /**

View File

@ -42,7 +42,7 @@ class CompletePackageTest extends TestCase
$versionParser = new VersionParser(); $versionParser = new VersionParser();
$normVersion = $versionParser->normalize($version); $normVersion = $versionParser->normalize($version);
$package = new Package($name, $normVersion, $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(); $versionParser = new VersionParser();
$normVersion = $versionParser->normalize($version); $normVersion = $versionParser->normalize($version);
$package = new Package($name, $normVersion, $version); $package = new Package($name, $normVersion, $version);
$this->assertEquals($version, $package->getPrettyVersion()); self::assertEquals($version, $package->getPrettyVersion());
$this->assertEquals($normVersion, $package->getVersion()); self::assertEquals($normVersion, $package->getVersion());
} }
/** /**
@ -65,34 +65,34 @@ class CompletePackageTest extends TestCase
$versionParser = new VersionParser(); $versionParser = new VersionParser();
$normVersion = $versionParser->normalize($version); $normVersion = $versionParser->normalize($version);
$package = new Package($name, $normVersion, $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 public function testGetTargetDir(): void
{ {
$package = new Package('a', '1.0.0.0', '1.0'); $package = new Package('a', '1.0.0.0', '1.0');
$this->assertNull($package->getTargetDir()); self::assertNull($package->getTargetDir());
$package->setTargetDir('./../foo/'); $package->setTargetDir('./../foo/');
$this->assertEquals('foo/', $package->getTargetDir()); self::assertEquals('foo/', $package->getTargetDir());
$package->setTargetDir('foo/../../../bar/'); $package->setTargetDir('foo/../../../bar/');
$this->assertEquals('foo/bar/', $package->getTargetDir()); self::assertEquals('foo/bar/', $package->getTargetDir());
$package->setTargetDir('../..'); $package->setTargetDir('../..');
$this->assertEquals('', $package->getTargetDir()); self::assertEquals('', $package->getTargetDir());
$package->setTargetDir('..'); $package->setTargetDir('..');
$this->assertEquals('', $package->getTargetDir()); self::assertEquals('', $package->getTargetDir());
$package->setTargetDir('/..'); $package->setTargetDir('/..');
$this->assertEquals('', $package->getTargetDir()); self::assertEquals('', $package->getTargetDir());
$package->setTargetDir('/foo/..'); $package->setTargetDir('/foo/..');
$this->assertEquals('foo/', $package->getTargetDir()); self::assertEquals('foo/', $package->getTargetDir());
$package->setTargetDir('/foo/..//bar'); $package->setTargetDir('/foo/..//bar');
$this->assertEquals('foo/bar', $package->getTargetDir()); self::assertEquals('foo/bar', $package->getTargetDir());
} }
} }

View File

@ -32,7 +32,7 @@ class ArrayDumperTest extends TestCase
public function testRequiredInformation(): void public function testRequiredInformation(): void
{ {
$config = $this->dumper->dump(self::getPackage()); $config = $this->dumper->dump(self::getPackage());
$this->assertEquals( self::assertEquals(
[ [
'name' => 'dummy/pkg', 'name' => 'dummy/pkg',
'version' => '1.0.0', 'version' => '1.0.0',
@ -49,7 +49,7 @@ class ArrayDumperTest extends TestCase
$package->setMinimumStability('dev'); $package->setMinimumStability('dev');
$config = $this->dumper->dump($package); $config = $this->dumper->dump($package);
$this->assertSame('dev', $config['minimum-stability']); self::assertSame('dev', $config['minimum-stability']);
} }
public function testDumpAbandoned(): void public function testDumpAbandoned(): void
@ -58,7 +58,7 @@ class ArrayDumperTest extends TestCase
$package->setAbandoned(true); $package->setAbandoned(true);
$config = $this->dumper->dump($package); $config = $this->dumper->dump($package);
$this->assertTrue($config['abandoned']); self::assertTrue($config['abandoned']);
} }
public function testDumpAbandonedReplacement(): void public function testDumpAbandonedReplacement(): void
@ -67,7 +67,7 @@ class ArrayDumperTest extends TestCase
$package->setAbandoned('foo/bar'); $package->setAbandoned('foo/bar');
$config = $this->dumper->dump($package); $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(); $package = self::getRootPackage();
// @phpstan-ignore method.dynamicName, ternary.shortNotAllowed // @phpstan-ignore method.dynamicName
$package->{'set'.ucfirst($method ?: $key)}($value); $package->{'set'.ucfirst($method ?? $key)}($value);
$config = $this->dumper->dump($package); $config = $this->dumper->dump($package);
$this->assertSame($expectedValue ?: $value, $config[$key]); self::assertSame($expectedValue ?: $value, $config[$key]);
} }
public static function provideKeys(): array public static function provideKeys(): array

View File

@ -42,7 +42,7 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$replaces = $package->getReplaces(); $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 public function testTypeDefault(): void
@ -53,7 +53,7 @@ class ArrayLoaderTest extends TestCase
]; ];
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertEquals('library', $package->getType()); self::assertEquals('library', $package->getType());
$config = [ $config = [
'name' => 'A', 'name' => 'A',
@ -62,7 +62,7 @@ class ArrayLoaderTest extends TestCase
]; ];
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertEquals('foo', $package->getType()); self::assertEquals('foo', $package->getType());
} }
public function testNormalizedVersionOptimization(): void public function testNormalizedVersionOptimization(): void
@ -73,7 +73,7 @@ class ArrayLoaderTest extends TestCase
]; ];
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertEquals('1.2.3.0', $package->getVersion()); self::assertEquals('1.2.3.0', $package->getVersion());
$config = [ $config = [
'name' => 'A', 'name' => 'A',
@ -82,7 +82,7 @@ class ArrayLoaderTest extends TestCase
]; ];
$package = $this->loader->load($config); $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 public static function parseDumpProvider(): array
@ -161,7 +161,7 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$dumper = new ArrayDumper; $dumper = new ArrayDumper;
$expectedConfig = $this->fixConfigWhenLoadConfigIsFalse($config); $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); $package = $loader->load($config);
$dumper = new ArrayDumper; $dumper = new ArrayDumper;
$expectedConfig = $config; $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); $package = $loader->load($config);
$dumper = new ArrayDumper; $dumper = new ArrayDumper;
$expectedConfig = $this->fixConfigWhenLoadConfigIsFalse($config); $expectedConfig = $this->fixConfigWhenLoadConfigIsFalse($config);
$this->assertEquals($expectedConfig, $dumper->dump($package)); self::assertEquals($expectedConfig, $dumper->dump($package));
} }
public function testPackageWithBranchAlias(): void public function testPackageWithBranchAlias(): void
@ -202,8 +202,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\AliasPackage', $package); self::assertInstanceOf('Composer\Package\AliasPackage', $package);
$this->assertEquals('1.0.x-dev', $package->getPrettyVersion()); self::assertEquals('1.0.x-dev', $package->getPrettyVersion());
$config = [ $config = [
'name' => 'A', 'name' => 'A',
@ -213,8 +213,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\AliasPackage', $package); self::assertInstanceOf('Composer\Package\AliasPackage', $package);
$this->assertEquals('1.0.x-dev', $package->getPrettyVersion()); self::assertEquals('1.0.x-dev', $package->getPrettyVersion());
$config = [ $config = [
'name' => 'B', 'name' => 'B',
@ -224,8 +224,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\AliasPackage', $package); self::assertInstanceOf('Composer\Package\AliasPackage', $package);
$this->assertEquals('4.0.x-dev', $package->getPrettyVersion()); self::assertEquals('4.0.x-dev', $package->getPrettyVersion());
$config = [ $config = [
'name' => 'B', 'name' => 'B',
@ -235,8 +235,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\AliasPackage', $package); self::assertInstanceOf('Composer\Package\AliasPackage', $package);
$this->assertEquals('4.0.x-dev', $package->getPrettyVersion()); self::assertEquals('4.0.x-dev', $package->getPrettyVersion());
$config = [ $config = [
'name' => 'C', 'name' => 'C',
@ -246,8 +246,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\CompletePackage', $package); self::assertInstanceOf('Composer\Package\CompletePackage', $package);
$this->assertEquals('4.x-dev', $package->getPrettyVersion()); self::assertEquals('4.x-dev', $package->getPrettyVersion());
} }
public function testPackageAliasingWithoutBranchAlias(): void public function testPackageAliasingWithoutBranchAlias(): void
@ -261,8 +261,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\AliasPackage', $package); self::assertInstanceOf('Composer\Package\AliasPackage', $package);
$this->assertEquals(VersionParser::DEFAULT_BRANCH_ALIAS, $package->getPrettyVersion()); self::assertEquals(VersionParser::DEFAULT_BRANCH_ALIAS, $package->getPrettyVersion());
// non-default branch gets no alias even if non-numeric // non-default branch gets no alias even if non-numeric
$config = [ $config = [
@ -273,8 +273,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\CompletePackage', $package); self::assertInstanceOf('Composer\Package\CompletePackage', $package);
$this->assertEquals('dev-main', $package->getPrettyVersion()); self::assertEquals('dev-main', $package->getPrettyVersion());
// default branch gets no alias if already numeric // default branch gets no alias if already numeric
$config = [ $config = [
@ -285,8 +285,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\CompletePackage', $package); self::assertInstanceOf('Composer\Package\CompletePackage', $package);
$this->assertEquals('2.9999999.9999999.9999999-dev', $package->getVersion()); self::assertEquals('2.9999999.9999999.9999999-dev', $package->getVersion());
// default branch gets no alias if already numeric, with v prefix // default branch gets no alias if already numeric, with v prefix
$config = [ $config = [
@ -297,8 +297,8 @@ class ArrayLoaderTest extends TestCase
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertInstanceOf('Composer\Package\CompletePackage', $package); self::assertInstanceOf('Composer\Package\CompletePackage', $package);
$this->assertEquals('2.9999999.9999999.9999999-dev', $package->getVersion()); self::assertEquals('2.9999999.9999999.9999999-dev', $package->getVersion());
} }
public function testAbandoned(): void public function testAbandoned(): void
@ -310,8 +310,8 @@ class ArrayLoaderTest extends TestCase
]; ];
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertTrue($package->isAbandoned()); self::assertTrue($package->isAbandoned());
$this->assertEquals('foo/bar', $package->getReplacementPackage()); self::assertEquals('foo/bar', $package->getReplacementPackage());
} }
public function testNotAbandoned(): void public function testNotAbandoned(): void
@ -322,7 +322,7 @@ class ArrayLoaderTest extends TestCase
]; ];
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertFalse($package->isAbandoned()); self::assertFalse($package->isAbandoned());
} }
public static function providePluginApiVersions(): array 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]); $links = $this->loader->parseLinks('Plugin', '9.9.9', Link::TYPE_REQUIRE, ['composer-plugin-api' => $apiVersion]);
$this->assertArrayHasKey('composer-plugin-api', $links); self::assertArrayHasKey('composer-plugin-api', $links);
$this->assertSame($apiVersion, $links['composer-plugin-api']->getConstraint()->getPrettyString()); self::assertSame($apiVersion, $links['composer-plugin-api']->getConstraint()->getPrettyString());
} }
public function testPluginApiVersionDoesSupportSelfVersion(): void public function testPluginApiVersionDoesSupportSelfVersion(): void
{ {
$links = $this->loader->parseLinks('Plugin', '6.6.6', Link::TYPE_REQUIRE, ['composer-plugin-api' => 'self.version']); $links = $this->loader->parseLinks('Plugin', '6.6.6', Link::TYPE_REQUIRE, ['composer-plugin-api' => 'self.version']);
$this->assertArrayHasKey('composer-plugin-api', $links); self::assertArrayHasKey('composer-plugin-api', $links);
$this->assertSame('6.6.6', $links['composer-plugin-api']->getConstraint()->getPrettyString()); self::assertSame('6.6.6', $links['composer-plugin-api']->getConstraint()->getPrettyString());
} }
public function testParseLinksIntegerTarget(): void public function testParseLinksIntegerTarget(): void
{ {
$links = $this->loader->parseLinks('Plugin', '9.9.9', Link::TYPE_REQUIRE, ['1' => 'dev-main']); $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 public function testNoneStringVersion(): void
@ -380,7 +380,7 @@ class ArrayLoaderTest extends TestCase
]; ];
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertSame('1', $package->getPrettyVersion()); self::assertSame('1', $package->getPrettyVersion());
} }
public function testNoneStringSourceDistReference(): void public function testNoneStringSourceDistReference(): void
@ -401,8 +401,8 @@ class ArrayLoaderTest extends TestCase
]; ];
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertSame('2019', $package->getSourceReference()); self::assertSame('2019', $package->getSourceReference());
$this->assertSame('2019', $package->getDistReference()); self::assertSame('2019', $package->getDistReference());
} }
public function testBranchAliasIntegerIndex(): void 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 public function testPackageLinksRequire(): void
@ -435,8 +435,8 @@ class ArrayLoaderTest extends TestCase
); );
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertArrayHasKey('foo/bar', $package->getRequires()); self::assertArrayHasKey('foo/bar', $package->getRequires());
$this->assertSame('1.0', $package->getRequires()['foo/bar']->getConstraint()->getPrettyString()); self::assertSame('1.0', $package->getRequires()['foo/bar']->getConstraint()->getPrettyString());
} }
public function testPackageLinksRequireInvalid(): void public function testPackageLinksRequireInvalid(): void
@ -452,7 +452,7 @@ class ArrayLoaderTest extends TestCase
); );
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertCount(0, $package->getRequires()); self::assertCount(0, $package->getRequires());
} }
public function testPackageLinksReplace(): void public function testPackageLinksReplace(): void
@ -466,8 +466,8 @@ class ArrayLoaderTest extends TestCase
); );
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertArrayHasKey('coyote/package', $package->getReplaces()); self::assertArrayHasKey('coyote/package', $package->getReplaces());
$this->assertSame('dev-1', $package->getReplaces()['coyote/package']->getConstraint()->getPrettyString()); self::assertSame('dev-1', $package->getReplaces()['coyote/package']->getConstraint()->getPrettyString());
} }
public function testPackageLinksReplaceInvalid(): void public function testPackageLinksReplaceInvalid(): void
@ -479,7 +479,7 @@ class ArrayLoaderTest extends TestCase
); );
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertCount(0, $package->getReplaces()); self::assertCount(0, $package->getReplaces());
} }
public function testSupportStringValue(): void public function testSupportStringValue(): void
@ -491,6 +491,6 @@ class ArrayLoaderTest extends TestCase
); );
$package = $this->loader->load($config); $package = $this->loader->load($config);
$this->assertSame([], $package->getSupport()); self::assertSame([], $package->getSupport());
} }
} }

View File

@ -62,8 +62,8 @@ class RootPackageLoaderTest extends TestCase
'minimum-stability' => 'alpha', 'minimum-stability' => 'alpha',
]); ]);
$this->assertEquals('alpha', $package->getMinimumStability()); self::assertEquals('alpha', $package->getMinimumStability());
$this->assertEquals([ self::assertEquals([
'bar/baz' => BasePackage::STABILITY_DEV, 'bar/baz' => BasePackage::STABILITY_DEV,
'qux/quux' => BasePackage::STABILITY_RC, 'qux/quux' => BasePackage::STABILITY_RC,
'zux/complex' => BasePackage::STABILITY_DEV, 'zux/complex' => BasePackage::STABILITY_DEV,
@ -88,8 +88,8 @@ class RootPackageLoaderTest extends TestCase
$package = $loader->load([]); $package = $loader->load([]);
$this->assertEquals("1.0.0.0", $package->getVersion()); self::assertEquals("1.0.0.0", $package->getVersion());
$this->assertEquals(RootPackage::DEFAULT_PRETTY_VERSION, $package->getPrettyVersion()); self::assertEquals(RootPackage::DEFAULT_PRETTY_VERSION, $package->getPrettyVersion());
} }
public function testPrettyVersionForRootPackageInVersionBranch(): void public function testPrettyVersionForRootPackageInVersionBranch(): void
@ -110,7 +110,7 @@ class RootPackageLoaderTest extends TestCase
$loader = new RootPackageLoader($manager, $config, null, $versionGuesser); $loader = new RootPackageLoader($manager, $config, null, $versionGuesser);
$package = $loader->load([]); $package = $loader->load([]);
$this->assertEquals('3.0-dev', $package->getPrettyVersion()); self::assertEquals('3.0-dev', $package->getPrettyVersion());
} }
public function testFeatureBranchPrettyVersion(): void public function testFeatureBranchPrettyVersion(): void
@ -138,7 +138,7 @@ class RootPackageLoaderTest extends TestCase
$loader = new RootPackageLoader($manager, $config, null, new VersionGuesser($config, $process, new VersionParser())); $loader = new RootPackageLoader($manager, $config, null, new VersionGuesser($config, $process, new VersionParser()));
$package = $loader->load(['require' => ['foo/bar' => 'self.version']]); $package = $loader->load(['require' => ['foo/bar' => 'self.version']]);
$this->assertEquals("dev-master", $package->getPrettyVersion()); self::assertEquals("dev-master", $package->getPrettyVersion());
} }
public function testNonFeatureBranchPrettyVersion(): void public function testNonFeatureBranchPrettyVersion(): void
@ -165,6 +165,6 @@ class RootPackageLoaderTest extends TestCase
$loader = new RootPackageLoader($manager, $config, null, new VersionGuesser($config, $process, new VersionParser())); $loader = new RootPackageLoader($manager, $config, null, new VersionGuesser($config, $process, new VersionParser()));
$package = $loader->load(['require' => ['foo/bar' => 'self.version'], "non-feature-branches" => ["latest-.*"]]); $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());
} }
} }

View File

@ -224,7 +224,7 @@ class ValidatingArrayLoaderTest extends TestCase
$errors = $e->getErrors(); $errors = $e->getErrors();
sort($expectedErrors); sort($expectedErrors);
sort($errors); sort($errors);
$this->assertEquals($expectedErrors, $errors); self::assertEquals($expectedErrors, $errors);
} }
} }
@ -243,7 +243,7 @@ class ValidatingArrayLoaderTest extends TestCase
$warnings = $loader->getWarnings(); $warnings = $loader->getWarnings();
sort($expectedWarnings); sort($expectedWarnings);
sort($warnings); 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 public function testLoadSkipsWarningDataWhenIgnoringErrors(array $config, array $expectedWarnings, bool $mustCheck = true): void
{ {
if (!$mustCheck) { if (!$mustCheck) {
$this->assertTrue(true); self::assertTrue(true); // @phpstan-ignore staticMethod.alreadyNarrowedType
return; return;
} }

View File

@ -39,7 +39,7 @@ class LockerTest extends TestCase
->method('read') ->method('read')
->will($this->returnValue(['packages' => []])); ->will($this->returnValue(['packages' => []]));
$this->assertTrue($locker->isLocked()); self::assertTrue($locker->isLocked());
} }
public function testGetNotLockedPackages(): void public function testGetNotLockedPackages(): void
@ -81,8 +81,8 @@ class LockerTest extends TestCase
])); ]));
$repo = $locker->getLockedRepository(); $repo = $locker->getLockedRepository();
$this->assertNotNull($repo->findPackage('pkg1', '1.0.0-beta')); self::assertNotNull($repo->findPackage('pkg1', '1.0.0-beta'));
$this->assertNotNull($repo->findPackage('pkg2', '0.1.10')); self::assertNotNull($repo->findPackage('pkg2', '0.1.10'));
} }
public function testSetLockData(): void public function testSetLockData(): void
@ -156,7 +156,7 @@ class LockerTest extends TestCase
->method('read') ->method('read')
->will($this->returnValue(['hash' => md5($jsonContent)])); ->will($this->returnValue(['hash' => md5($jsonContent)]));
$this->assertTrue($locker->isFresh()); self::assertTrue($locker->isFresh());
} }
public function testIsFreshFalse(): void public function testIsFreshFalse(): void
@ -171,7 +171,7 @@ class LockerTest extends TestCase
->method('read') ->method('read')
->will($this->returnValue(['hash' => $this->getJsonContent(['name' => 'test2'])])); ->will($this->returnValue(['hash' => $this->getJsonContent(['name' => 'test2'])]));
$this->assertFalse($locker->isFresh()); self::assertFalse($locker->isFresh());
} }
public function testIsFreshWithContentHash(): void public function testIsFreshWithContentHash(): void
@ -187,7 +187,7 @@ class LockerTest extends TestCase
->method('read') ->method('read')
->will($this->returnValue(['hash' => md5($jsonContent . ' '), 'content-hash' => md5($jsonContent)])); ->will($this->returnValue(['hash' => md5($jsonContent . ' '), 'content-hash' => md5($jsonContent)]));
$this->assertTrue($locker->isFresh()); self::assertTrue($locker->isFresh());
} }
public function testIsFreshWithContentHashAndNoHash(): void public function testIsFreshWithContentHashAndNoHash(): void
@ -203,7 +203,7 @@ class LockerTest extends TestCase
->method('read') ->method('read')
->will($this->returnValue(['content-hash' => md5($jsonContent)])); ->will($this->returnValue(['content-hash' => md5($jsonContent)]));
$this->assertTrue($locker->isFresh()); self::assertTrue($locker->isFresh());
} }
public function testIsFreshFalseWithContentHash(): void public function testIsFreshFalseWithContentHash(): void
@ -220,7 +220,7 @@ class LockerTest extends TestCase
->method('read') ->method('read')
->will($this->returnValue(['hash' => $differentHash, 'content-hash' => $differentHash])); ->will($this->returnValue(['hash' => $differentHash, 'content-hash' => $differentHash]));
$this->assertFalse($locker->isFresh()); self::assertFalse($locker->isFresh());
} }
/** /**

View File

@ -31,9 +31,9 @@ class RootAliasPackageTest extends TestCase
->with($this->equalTo($links)); ->with($this->equalTo($links));
$alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0');
$this->assertEmpty($alias->getRequires()); self::assertEmpty($alias->getRequires());
$alias->setRequires($links); $alias->setRequires($links);
$this->assertNotEmpty($alias->getRequires()); self::assertNotEmpty($alias->getRequires());
} }
public function testUpdateDevRequires(): void public function testUpdateDevRequires(): void
@ -46,9 +46,9 @@ class RootAliasPackageTest extends TestCase
->with($this->equalTo($links)); ->with($this->equalTo($links));
$alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0');
$this->assertEmpty($alias->getDevRequires()); self::assertEmpty($alias->getDevRequires());
$alias->setDevRequires($links); $alias->setDevRequires($links);
$this->assertNotEmpty($alias->getDevRequires()); self::assertNotEmpty($alias->getDevRequires());
} }
public function testUpdateConflicts(): void public function testUpdateConflicts(): void
@ -61,9 +61,9 @@ class RootAliasPackageTest extends TestCase
->with($this->equalTo($links)); ->with($this->equalTo($links));
$alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0');
$this->assertEmpty($alias->getConflicts()); self::assertEmpty($alias->getConflicts());
$alias->setConflicts($links); $alias->setConflicts($links);
$this->assertNotEmpty($alias->getConflicts()); self::assertNotEmpty($alias->getConflicts());
} }
public function testUpdateProvides(): void public function testUpdateProvides(): void
@ -76,9 +76,9 @@ class RootAliasPackageTest extends TestCase
->with($this->equalTo($links)); ->with($this->equalTo($links));
$alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0');
$this->assertEmpty($alias->getProvides()); self::assertEmpty($alias->getProvides());
$alias->setProvides($links); $alias->setProvides($links);
$this->assertNotEmpty($alias->getProvides()); self::assertNotEmpty($alias->getProvides());
} }
public function testUpdateReplaces(): void public function testUpdateReplaces(): void
@ -91,9 +91,9 @@ class RootAliasPackageTest extends TestCase
->with($this->equalTo($links)); ->with($this->equalTo($links));
$alias = new RootAliasPackage($root, '1.0', '1.0.0.0'); $alias = new RootAliasPackage($root, '1.0', '1.0.0.0');
$this->assertEmpty($alias->getReplaces()); self::assertEmpty($alias->getReplaces());
$alias->setReplaces($links); $alias->setReplaces($links);
$this->assertNotEmpty($alias->getReplaces()); self::assertNotEmpty($alias->getReplaces());
} }
/** /**

View File

@ -37,7 +37,7 @@ class VersionBumperTest extends TestCase
$newConstraint = $versionBumper->bumpRequirement($versionParser->parseConstraints($requirement), $package); $newConstraint = $versionBumper->bumpRequirement($versionParser->parseConstraints($requirement), $package);
// assert that the recommended version is what we expect // assert that the recommended version is what we expect
$this->assertSame($expectedRequirement, $newConstraint); self::assertSame($expectedRequirement, $newConstraint);
} }
public static function provideBumpRequirementTests(): Generator public static function provideBumpRequirementTests(): Generator

View File

@ -50,9 +50,9 @@ class VersionGuesserTest extends TestCase
$versionArray = $guesser->guessVersion([], 'dummy/path'); $versionArray = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionArray); self::assertIsArray($versionArray);
$this->assertEquals("dev-".$branch, $versionArray['version']); self::assertEquals("dev-".$branch, $versionArray['version']);
$this->assertEquals("dev-".$branch, $versionArray['pretty_version']); self::assertEquals("dev-".$branch, $versionArray['pretty_version']);
$this->assertEmpty($versionArray['commit']); self::assertEmpty($versionArray['commit']);
} }
public function testGuessVersionReturnsData(): void public function testGuessVersionReturnsData(): void
@ -74,11 +74,11 @@ class VersionGuesserTest extends TestCase
$versionArray = $guesser->guessVersion([], 'dummy/path'); $versionArray = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionArray); self::assertIsArray($versionArray);
$this->assertEquals("dev-master", $versionArray['version']); self::assertEquals("dev-master", $versionArray['version']);
$this->assertEquals("dev-master", $versionArray['pretty_version']); self::assertEquals("dev-master", $versionArray['pretty_version']);
$this->assertArrayNotHasKey('feature_version', $versionArray); self::assertArrayNotHasKey('feature_version', $versionArray);
$this->assertArrayNotHasKey('feature_pretty_version', $versionArray); self::assertArrayNotHasKey('feature_pretty_version', $versionArray);
$this->assertEquals($commitHash, $versionArray['commit']); self::assertEquals($commitHash, $versionArray['commit']);
} }
public function testGuessVersionDoesNotSeeCustomDefaultBranchAsNonFeatureBranch(): void public function testGuessVersionDoesNotSeeCustomDefaultBranchAsNonFeatureBranch(): void
@ -101,8 +101,8 @@ class VersionGuesserTest extends TestCase
$versionArray = $guesser->guessVersion(['version' => 'self.version'], 'dummy/path'); $versionArray = $guesser->guessVersion(['version' => 'self.version'], 'dummy/path');
self::assertIsArray($versionArray); self::assertIsArray($versionArray);
$this->assertEquals("dev-current", $versionArray['version']); self::assertEquals("dev-current", $versionArray['version']);
$this->assertEquals($anotherCommitHash, $versionArray['commit']); self::assertEquals($anotherCommitHash, $versionArray['commit']);
} }
public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNaming(): void public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNaming(): void
@ -128,11 +128,11 @@ class VersionGuesserTest extends TestCase
$versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['arbitrary']], 'dummy/path'); $versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['arbitrary']], 'dummy/path');
self::assertIsArray($versionArray); self::assertIsArray($versionArray);
$this->assertEquals("dev-arbitrary", $versionArray['version']); self::assertEquals("dev-arbitrary", $versionArray['version']);
$this->assertEquals($anotherCommitHash, $versionArray['commit']); self::assertEquals($anotherCommitHash, $versionArray['commit']);
self::assertArrayHasKey('feature_version', $versionArray); self::assertArrayHasKey('feature_version', $versionArray);
$this->assertEquals("dev-feature", $versionArray['feature_version']); self::assertEquals("dev-feature", $versionArray['feature_version']);
$this->assertEquals("dev-feature", $versionArray['feature_pretty_version']); self::assertEquals("dev-feature", $versionArray['feature_pretty_version']);
} }
public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNamingRegex(): void public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNamingRegex(): void
@ -158,11 +158,11 @@ class VersionGuesserTest extends TestCase
$versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['latest-.*']], 'dummy/path'); $versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['latest-.*']], 'dummy/path');
self::assertIsArray($versionArray); self::assertIsArray($versionArray);
$this->assertEquals("dev-latest-testing", $versionArray['version']); self::assertEquals("dev-latest-testing", $versionArray['version']);
$this->assertEquals($anotherCommitHash, $versionArray['commit']); self::assertEquals($anotherCommitHash, $versionArray['commit']);
self::assertArrayHasKey('feature_version', $versionArray); self::assertArrayHasKey('feature_version', $versionArray);
$this->assertEquals("dev-feature", $versionArray['feature_version']); self::assertEquals("dev-feature", $versionArray['feature_version']);
$this->assertEquals("dev-feature", $versionArray['feature_pretty_version']); self::assertEquals("dev-feature", $versionArray['feature_pretty_version']);
} }
public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNamingWhenOnNonFeatureBranch(): void public function testGuessVersionReadsAndRespectsNonFeatureBranchesConfigurationForArbitraryNamingWhenOnNonFeatureBranch(): void
@ -184,10 +184,10 @@ class VersionGuesserTest extends TestCase
$versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['latest-.*']], 'dummy/path'); $versionArray = $guesser->guessVersion(['version' => 'self.version', 'non-feature-branches' => ['latest-.*']], 'dummy/path');
self::assertIsArray($versionArray); self::assertIsArray($versionArray);
$this->assertEquals("dev-latest-testing", $versionArray['version']); self::assertEquals("dev-latest-testing", $versionArray['version']);
$this->assertEquals($commitHash, $versionArray['commit']); self::assertEquals($commitHash, $versionArray['commit']);
$this->assertArrayNotHasKey('feature_version', $versionArray); self::assertArrayNotHasKey('feature_version', $versionArray);
$this->assertArrayNotHasKey('feature_pretty_version', $versionArray); self::assertArrayNotHasKey('feature_pretty_version', $versionArray);
} }
public function testDetachedHeadBecomesDevHash(): void public function testDetachedHeadBecomesDevHash(): void
@ -209,7 +209,7 @@ class VersionGuesserTest extends TestCase
$versionData = $guesser->guessVersion([], 'dummy/path'); $versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData); self::assertIsArray($versionData);
$this->assertEquals("dev-$commitHash", $versionData['version']); self::assertEquals("dev-$commitHash", $versionData['version']);
} }
public function testDetachedFetchHeadBecomesDevHashGit2(): void public function testDetachedFetchHeadBecomesDevHashGit2(): void
@ -231,7 +231,7 @@ class VersionGuesserTest extends TestCase
$versionData = $guesser->guessVersion([], 'dummy/path'); $versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData); self::assertIsArray($versionData);
$this->assertEquals("dev-$commitHash", $versionData['version']); self::assertEquals("dev-$commitHash", $versionData['version']);
} }
public function testDetachedCommitHeadBecomesDevHashGit2(): void public function testDetachedCommitHeadBecomesDevHashGit2(): void
@ -253,7 +253,7 @@ class VersionGuesserTest extends TestCase
$versionData = $guesser->guessVersion([], 'dummy/path'); $versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData); self::assertIsArray($versionData);
$this->assertEquals("dev-$commitHash", $versionData['version']); self::assertEquals("dev-$commitHash", $versionData['version']);
} }
public function testTagBecomesVersion(): void public function testTagBecomesVersion(): void
@ -276,7 +276,7 @@ class VersionGuesserTest extends TestCase
$versionData = $guesser->guessVersion([], 'dummy/path'); $versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData); 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 public function testTagBecomesPrettyVersion(): void
@ -299,8 +299,8 @@ class VersionGuesserTest extends TestCase
$versionData = $guesser->guessVersion([], 'dummy/path'); $versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData); self::assertIsArray($versionData);
$this->assertEquals('1.0.0.0', $versionData['version']); self::assertEquals('1.0.0.0', $versionData['version']);
$this->assertEquals('1.0.0', $versionData['pretty_version']); self::assertEquals('1.0.0', $versionData['pretty_version']);
} }
public function testInvalidTagBecomesVersion(): void public function testInvalidTagBecomesVersion(): void
@ -319,7 +319,7 @@ class VersionGuesserTest extends TestCase
$versionData = $guesser->guessVersion([], 'dummy/path'); $versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData); self::assertIsArray($versionData);
$this->assertEquals("dev-foo", $versionData['version']); self::assertEquals("dev-foo", $versionData['version']);
} }
public function testNumericBranchesShowNicely(): void public function testNumericBranchesShowNicely(): void
@ -338,8 +338,8 @@ class VersionGuesserTest extends TestCase
$versionData = $guesser->guessVersion([], 'dummy/path'); $versionData = $guesser->guessVersion([], 'dummy/path');
self::assertIsArray($versionData); self::assertIsArray($versionData);
$this->assertEquals("1.5.x-dev", $versionData['pretty_version']); self::assertEquals("1.5.x-dev", $versionData['pretty_version']);
$this->assertEquals("1.5.9999999.9999999-dev", $versionData['version']); self::assertEquals("1.5.9999999.9999999-dev", $versionData['version']);
} }
public function testRemoteBranchesAreSelected(): void public function testRemoteBranchesAreSelected(): void
@ -362,7 +362,7 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $process, new VersionParser()); $guesser = new VersionGuesser($config, $process, new VersionParser());
$versionData = $guesser->guessVersion(['version' => 'self.version'], 'dummy/path'); $versionData = $guesser->guessVersion(['version' => 'self.version'], 'dummy/path');
self::assertIsArray($versionData); self::assertIsArray($versionData);
$this->assertEquals("1.5.x-dev", $versionData['pretty_version']); self::assertEquals("1.5.x-dev", $versionData['pretty_version']);
$this->assertEquals("1.5.9999999.9999999-dev", $versionData['version']); self::assertEquals("1.5.9999999.9999999-dev", $versionData['version']);
} }
} }

View File

@ -27,7 +27,7 @@ class VersionParserTest extends TestCase
{ {
$versionParser = new VersionParser(); $versionParser = new VersionParser();
$this->assertSame($result, $versionParser->parseNameVersionPairs($pairs)); self::assertSame($result, $versionParser->parseNameVersionPairs($pairs));
} }
public static function provideParseNameVersionPairsData(): array public static function provideParseNameVersionPairsData(): array
@ -46,7 +46,7 @@ class VersionParserTest extends TestCase
*/ */
public function testIsUpgrade(string $from, string $to, bool $expected): void 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 public static function provideIsUpgradeTests(): array

View File

@ -48,7 +48,7 @@ class VersionSelectorTest extends TestCase
$best = $versionSelector->findBestCandidate($packageName); $best = $versionSelector->findBestCandidate($packageName);
// 1.2.2 should be returned because it's the latest of the returned versions // 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 public function testLatestVersionIsReturnedThatMatchesPhpRequirements(): void
@ -77,12 +77,12 @@ class VersionSelectorTest extends TestCase
$io = new BufferIO(); $io = new BufferIO();
$best = $versionSelector->findBestCandidate($packageName, null, 'stable', null, 0, $io); $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("<warning>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()); self::assertSame("<warning>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); $io = new BufferIO('', StreamOutput::VERBOSITY_VERBOSE);
$best = $versionSelector->findBestCandidate($packageName, null, 'stable', null, 0, $io); $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( self::assertSame(
"<warning>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 "<warning>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
."<warning>Cannot use foo/bar 2.0.0 as it requires php >=5.6 which is not satisfied by your platform.".PHP_EOL, ."<warning>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()); $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 public function testLatestVersionIsReturnedThatMatchesExtRequirements(): void
@ -114,9 +114,9 @@ class VersionSelectorTest extends TestCase
->will($this->returnValue($packages)); ->will($this->returnValue($packages));
$best = $versionSelector->findBestCandidate($packageName); $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()); $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 public function testLatestVersionIsReturnedThatMatchesPlatformExt(): void
@ -139,9 +139,9 @@ class VersionSelectorTest extends TestCase
->will($this->returnValue($packages)); ->will($this->returnValue($packages));
$best = $versionSelector->findBestCandidate($packageName); $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()); $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 public function testLatestVersionIsReturnedThatMatchesComposerRequirements(): void
@ -165,9 +165,9 @@ class VersionSelectorTest extends TestCase
->will($this->returnValue($packages)); ->will($this->returnValue($packages));
$best = $versionSelector->findBestCandidate($packageName); $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()); $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 public function testMostStableVersionIsReturned(): void
@ -187,7 +187,7 @@ class VersionSelectorTest extends TestCase
$versionSelector = new VersionSelector($repositorySet); $versionSelector = new VersionSelector($repositorySet);
$best = $versionSelector->findBestCandidate($packageName); $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 public function testMostStableVersionIsReturnedRegardlessOfOrder(): void
@ -209,10 +209,10 @@ class VersionSelectorTest extends TestCase
$versionSelector = new VersionSelector($repositorySet); $versionSelector = new VersionSelector($repositorySet);
$best = $versionSelector->findBestCandidate($packageName); $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); $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 public function testHighestVersionIsReturned(): void
@ -232,7 +232,7 @@ class VersionSelectorTest extends TestCase
$versionSelector = new VersionSelector($repositorySet); $versionSelector = new VersionSelector($repositorySet);
$best = $versionSelector->findBestCandidate($packageName, null, 'dev'); $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 public function testHighestVersionMatchingStabilityIsReturned(): void
@ -253,7 +253,7 @@ class VersionSelectorTest extends TestCase
$versionSelector = new VersionSelector($repositorySet); $versionSelector = new VersionSelector($repositorySet);
$best = $versionSelector->findBestCandidate($packageName, null, 'beta'); $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 public function testMostStableUnstableVersionIsReturned(): void
@ -273,7 +273,7 @@ class VersionSelectorTest extends TestCase
$versionSelector = new VersionSelector($repositorySet); $versionSelector = new VersionSelector($repositorySet);
$best = $versionSelector->findBestCandidate($packageName, null, 'stable'); $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 public function testDefaultBranchAliasIsNeverReturned(): void
@ -294,7 +294,7 @@ class VersionSelectorTest extends TestCase
$versionSelector = new VersionSelector($repositorySet); $versionSelector = new VersionSelector($repositorySet);
$best = $versionSelector->findBestCandidate($packageName, null, 'dev'); $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 public function testFalseReturnedOnNoPackages(): void
@ -306,7 +306,7 @@ class VersionSelectorTest extends TestCase
$versionSelector = new VersionSelector($repositorySet); $versionSelector = new VersionSelector($repositorySet);
$best = $versionSelector->findBestCandidate('foobaz'); $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); $recommended = $versionSelector->findRecommendedRequireVersion($package);
// assert that the recommended version is what we expect // assert that the recommended version is what we expect
$this->assertSame($expectedVersion, $recommended); self::assertSame($expectedVersion, $recommended);
} }
public static function provideRecommendedRequireVersionPackages(): array public static function provideRecommendedRequireVersionPackages(): array

View File

@ -160,8 +160,8 @@ class PluginInstallerTest extends TestCase
$installer->install($this->repository, $this->packages[0]); $installer->install($this->repository, $this->packages[0]);
$plugins = $this->pm->getPlugins(); $plugins = $this->pm->getPlugins();
$this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound self::assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore property.notFound
$this->assertEquals( self::assertEquals(
'activate v1'.PHP_EOL, 'activate v1'.PHP_EOL,
$this->io->getOutput() $this->io->getOutput()
); );
@ -182,11 +182,11 @@ class PluginInstallerTest extends TestCase
$installer->install($this->repository, $this->packages[0]); $installer->install($this->repository, $this->packages[0]);
$plugins = $this->pm->getPlugins(); $plugins = $this->pm->getPlugins();
$this->assertEquals( self::assertEquals(
'activate v1'.PHP_EOL, 'activate v1'.PHP_EOL,
$this->io->getOutput() $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 public function testInstallMultiplePlugins(): void
@ -201,11 +201,11 @@ class PluginInstallerTest extends TestCase
$installer->install($this->repository, $this->packages[3]); $installer->install($this->repository, $this->packages[3]);
$plugins = $this->pm->getPlugins(); $plugins = $this->pm->getPlugins();
$this->assertEquals('plugin1', $plugins[0]->name); // @phpstan-ignore staticMethod.dynamicCall, property.notFound self::assertEquals('plugin1', $plugins[0]->name); // @phpstan-ignore property.notFound
$this->assertEquals('installer-v4', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound self::assertEquals('installer-v4', $plugins[0]->version); // @phpstan-ignore property.notFound
$this->assertEquals('plugin2', $plugins[1]->name); // @phpstan-ignore staticMethod.dynamicCall, property.notFound self::assertEquals('plugin2', $plugins[1]->name); // @phpstan-ignore property.notFound
$this->assertEquals('installer-v4', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound self::assertEquals('installer-v4', $plugins[1]->version); // @phpstan-ignore property.notFound
$this->assertEquals('activate v4-plugin1'.PHP_EOL.'activate v4-plugin2'.PHP_EOL, $this->io->getOutput()); self::assertEquals('activate v4-plugin1'.PHP_EOL.'activate v4-plugin2'.PHP_EOL, $this->io->getOutput());
} }
public function testUpgradeWithNewClassName(): void public function testUpgradeWithNewClassName(): void
@ -224,9 +224,9 @@ class PluginInstallerTest extends TestCase
$installer->update($this->repository, $this->packages[0], $this->packages[1]); $installer->update($this->repository, $this->packages[0], $this->packages[1]);
$plugins = $this->pm->getPlugins(); $plugins = $this->pm->getPlugins();
$this->assertCount(1, $plugins); self::assertCount(1, $plugins);
$this->assertEquals('installer-v2', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound self::assertEquals('installer-v2', $plugins[1]->version); // @phpstan-ignore property.notFound
$this->assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'activate v2'.PHP_EOL, $this->io->getOutput()); self::assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'activate v2'.PHP_EOL, $this->io->getOutput());
} }
public function testUninstall(): void public function testUninstall(): void
@ -245,8 +245,8 @@ class PluginInstallerTest extends TestCase
$installer->uninstall($this->repository, $this->packages[0]); $installer->uninstall($this->repository, $this->packages[0]);
$plugins = $this->pm->getPlugins(); $plugins = $this->pm->getPlugins();
$this->assertCount(0, $plugins); self::assertCount(0, $plugins);
$this->assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'uninstall v1'.PHP_EOL, $this->io->getOutput()); self::assertEquals('activate v1'.PHP_EOL.'deactivate v1'.PHP_EOL.'uninstall v1'.PHP_EOL, $this->io->getOutput());
} }
public function testUpgradeWithSameClassName(): void public function testUpgradeWithSameClassName(): void
@ -265,8 +265,8 @@ class PluginInstallerTest extends TestCase
$installer->update($this->repository, $this->packages[1], $this->packages[2]); $installer->update($this->repository, $this->packages[1], $this->packages[2]);
$plugins = $this->pm->getPlugins(); $plugins = $this->pm->getPlugins();
$this->assertEquals('installer-v3', $plugins[1]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound self::assertEquals('installer-v3', $plugins[1]->version); // @phpstan-ignore property.notFound
$this->assertEquals('activate v2'.PHP_EOL.'deactivate v2'.PHP_EOL.'activate v3'.PHP_EOL, $this->io->getOutput()); self::assertEquals('activate v2'.PHP_EOL.'deactivate v2'.PHP_EOL.'activate v3'.PHP_EOL, $this->io->getOutput());
} }
public function testRegisterPluginOnlyOneTime(): void public function testRegisterPluginOnlyOneTime(): void
@ -282,9 +282,9 @@ class PluginInstallerTest extends TestCase
$installer->install($this->repository, clone $this->packages[0]); $installer->install($this->repository, clone $this->packages[0]);
$plugins = $this->pm->getPlugins(); $plugins = $this->pm->getPlugins();
$this->assertCount(1, $plugins); self::assertCount(1, $plugins);
$this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore staticMethod.dynamicCall, property.notFound self::assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore property.notFound
$this->assertEquals('activate v1'.PHP_EOL, $this->io->getOutput()); self::assertEquals('activate v1'.PHP_EOL, $this->io->getOutput());
} }
/** /**
@ -325,16 +325,16 @@ class PluginInstallerTest extends TestCase
$starVersionPlugin = [$this->packages[4]]; $starVersionPlugin = [$this->packages[4]];
$this->setPluginApiVersionWithPlugins('1.0.0', $starVersionPlugin); $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->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->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->setPluginApiVersionWithPlugins('100.0.0-stable', $starVersionPlugin);
$this->assertCount(1, $this->pm->getPlugins()); self::assertCount(1, $this->pm->getPlugins());
} }
public function testPluginConstraintWorksOnlyWithCertainAPIVersion(): void public function testPluginConstraintWorksOnlyWithCertainAPIVersion(): void
@ -342,16 +342,16 @@ class PluginInstallerTest extends TestCase
$pluginWithApiConstraint = [$this->packages[5]]; $pluginWithApiConstraint = [$this->packages[5]];
$this->setPluginApiVersionWithPlugins('1.0.0', $pluginWithApiConstraint); $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->setPluginApiVersionWithPlugins('1.1.9', $pluginWithApiConstraint);
$this->assertCount(0, $this->pm->getPlugins()); self::assertCount(0, $this->pm->getPlugins());
$this->setPluginApiVersionWithPlugins('1.2.0', $pluginWithApiConstraint); $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->setPluginApiVersionWithPlugins('1.9.9', $pluginWithApiConstraint);
$this->assertCount(1, $this->pm->getPlugins()); self::assertCount(1, $this->pm->getPlugins());
} }
public function testPluginRangeConstraintsWorkOnlyWithCertainAPIVersion(): void public function testPluginRangeConstraintsWorkOnlyWithCertainAPIVersion(): void
@ -359,13 +359,13 @@ class PluginInstallerTest extends TestCase
$pluginWithApiConstraint = [$this->packages[6]]; $pluginWithApiConstraint = [$this->packages[6]];
$this->setPluginApiVersionWithPlugins('1.0.0', $pluginWithApiConstraint); $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->setPluginApiVersionWithPlugins('3.0.0', $pluginWithApiConstraint);
$this->assertCount(1, $this->pm->getPlugins()); self::assertCount(1, $this->pm->getPlugins());
$this->setPluginApiVersionWithPlugins('5.5.0', $pluginWithApiConstraint); $this->setPluginApiVersionWithPlugins('5.5.0', $pluginWithApiConstraint);
$this->assertCount(0, $this->pm->getPlugins()); self::assertCount(0, $this->pm->getPlugins());
} }
public function testCommandProviderCapability(): void public function testCommandProviderCapability(): void
@ -379,19 +379,19 @@ class PluginInstallerTest extends TestCase
/** @var \Composer\Plugin\Capability\CommandProvider[] $caps */ /** @var \Composer\Plugin\Capability\CommandProvider[] $caps */
$caps = $this->pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', ['composer' => $this->composer, 'io' => $this->io]); $caps = $this->pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', ['composer' => $this->composer, 'io' => $this->io]);
$this->assertCount(1, $caps); self::assertCount(1, $caps);
$this->assertInstanceOf('Composer\Plugin\Capability\CommandProvider', $caps[0]); self::assertInstanceOf('Composer\Plugin\Capability\CommandProvider', $caps[0]);
$commands = $caps[0]->getCommands(); $commands = $caps[0]->getCommands();
$this->assertCount(1, $commands); self::assertCount(1, $commands);
$this->assertInstanceOf('Composer\Command\BaseCommand', $commands[0]); self::assertInstanceOf('Composer\Command\BaseCommand', $commands[0]);
} }
public function testIncapablePluginIsCorrectlyDetected(): void public function testIncapablePluginIsCorrectlyDetected(): void
{ {
$plugin = $this->getMockBuilder('Composer\Plugin\PluginInterface') $plugin = $this->getMockBuilder('Composer\Plugin\PluginInterface')
->getMock(); ->getMock();
$this->assertNull($this->pm->getPluginCapability($plugin, 'Fake\Ability')); self::assertNull($this->pm->getPluginCapability($plugin, 'Fake\Ability'));
} }
public function testCapabilityImplementsComposerPluginApiClassAndIsConstructedWithArgs(): void public function testCapabilityImplementsComposerPluginApiClassAndIsConstructedWithArgs(): void
@ -411,9 +411,9 @@ class PluginInstallerTest extends TestCase
/** @var \Composer\Test\Plugin\Mock\Capability $capability */ /** @var \Composer\Test\Plugin\Mock\Capability $capability */
$capability = $this->pm->getPluginCapability($plugin, $capabilityApi, ['a' => 1, 'b' => 2]); $capability = $this->pm->getPluginCapability($plugin, $capabilityApi, ['a' => 1, 'b' => 2]);
$this->assertInstanceOf($capabilityApi, $capability); self::assertInstanceOf($capabilityApi, $capability);
$this->assertInstanceOf($capabilityImplementation, $capability); self::assertInstanceOf($capabilityImplementation, $capability);
$this->assertSame(['a' => 1, 'b' => 2, 'plugin' => $plugin], $capability->args); self::assertSame(['a' => 1, 'b' => 2, 'plugin' => $plugin], $capability->args);
} }
/** @return mixed[] */ /** @return mixed[] */
@ -467,7 +467,7 @@ class PluginInstallerTest extends TestCase
return []; return [];
})); }));
$this->assertNull($this->pm->getPluginCapability($plugin, $capabilityApi)); self::assertNull($this->pm->getPluginCapability($plugin, $capabilityApi));
} }
/** @return mixed[] */ /** @return mixed[] */

View File

@ -63,7 +63,7 @@ class StrictConfirmationQuestionTest extends TestCase
[$input, $dialog] = $this->createInput($question."\n"); [$input, $dialog] = $this->createInput($question."\n");
$question = new StrictConfirmationQuestion('Do you like French fries?', $default); $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'); $question = new StrictConfirmationQuestion('Do you like French fries?', false, '/^ja$/i', '/^nein$/i');
[$input, $dialog] = $this->createInput("ja\n"); [$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"); [$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) protected function getInputStream(string $input)
{ {
$stream = fopen('php://memory', 'r+', false); $stream = fopen('php://memory', 'r+', false);
$this->assertNotFalse($stream); self::assertNotFalse($stream);
fwrite($stream, $input); fwrite($stream, $input);
rewind($stream); rewind($stream);

View File

@ -23,7 +23,7 @@ class ArrayRepositoryTest extends TestCase
$repo = new ArrayRepository; $repo = new ArrayRepository;
$repo->addPackage(self::getPackage('foo', '1')); $repo->addPackage(self::getPackage('foo', '1'));
$this->assertCount(1, $repo); self::assertCount(1, $repo);
} }
public function testRemovePackage(): void public function testRemovePackage(): void
@ -34,12 +34,12 @@ class ArrayRepositoryTest extends TestCase
$repo->addPackage(self::getPackage('foo', '1')); $repo->addPackage(self::getPackage('foo', '1'));
$repo->addPackage($package); $repo->addPackage($package);
$this->assertCount(2, $repo); self::assertCount(2, $repo);
$repo->removePackage(self::getPackage('foo', '1')); $repo->removePackage(self::getPackage('foo', '1'));
$this->assertCount(1, $repo); self::assertCount(1, $repo);
$this->assertEquals([$package], $repo->getPackages()); self::assertEquals([$package], $repo->getPackages());
} }
public function testHasPackage(): void public function testHasPackage(): void
@ -48,8 +48,8 @@ class ArrayRepositoryTest extends TestCase
$repo->addPackage(self::getPackage('foo', '1')); $repo->addPackage(self::getPackage('foo', '1'));
$repo->addPackage(self::getPackage('bar', '2')); $repo->addPackage(self::getPackage('bar', '2'));
$this->assertTrue($repo->hasPackage(self::getPackage('foo', '1'))); self::assertTrue($repo->hasPackage(self::getPackage('foo', '1')));
$this->assertFalse($repo->hasPackage(self::getPackage('bar', '1'))); self::assertFalse($repo->hasPackage(self::getPackage('bar', '1')));
} }
public function testFindPackages(): void public function testFindPackages(): void
@ -60,12 +60,12 @@ class ArrayRepositoryTest extends TestCase
$repo->addPackage(self::getPackage('bar', '3')); $repo->addPackage(self::getPackage('bar', '3'));
$foo = $repo->findPackages('foo'); $foo = $repo->findPackages('foo');
$this->assertCount(1, $foo); self::assertCount(1, $foo);
$this->assertEquals('foo', $foo[0]->getName()); self::assertEquals('foo', $foo[0]->getName());
$bar = $repo->findPackages('bar'); $bar = $repo->findPackages('bar');
$this->assertCount(2, $bar); self::assertCount(2, $bar);
$this->assertEquals('bar', $bar[0]->getName()); self::assertEquals('bar', $bar[0]->getName());
} }
public function testAutomaticallyAddAliasedPackageButNotRemove(): void public function testAutomaticallyAddAliasedPackageButNotRemove(): void
@ -77,13 +77,13 @@ class ArrayRepositoryTest extends TestCase
$repo->addPackage($alias); $repo->addPackage($alias);
$this->assertCount(2, $repo); self::assertCount(2, $repo);
$this->assertTrue($repo->hasPackage(self::getPackage('foo', '1'))); self::assertTrue($repo->hasPackage(self::getPackage('foo', '1')));
$this->assertTrue($repo->hasPackage(self::getPackage('foo', '2'))); self::assertTrue($repo->hasPackage(self::getPackage('foo', '2')));
$repo->removePackage($alias); $repo->removePackage($alias);
$this->assertCount(1, $repo); self::assertCount(1, $repo);
} }
public function testSearch(): void public function testSearch(): void
@ -93,17 +93,17 @@ class ArrayRepositoryTest extends TestCase
$repo->addPackage(self::getPackage('foo', '1')); $repo->addPackage(self::getPackage('foo', '1'));
$repo->addPackage(self::getPackage('bar', '1')); $repo->addPackage(self::getPackage('bar', '1'));
$this->assertSame( self::assertSame(
[['name' => 'foo', 'description' => null]], [['name' => 'foo', 'description' => null]],
$repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT) $repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT)
); );
$this->assertSame( self::assertSame(
[['name' => 'bar', 'description' => null]], [['name' => 'bar', 'description' => null]],
$repo->search('bar') $repo->search('bar')
); );
$this->assertEmpty( self::assertEmpty(
$repo->search('foobar') $repo->search('foobar')
); );
} }
@ -119,14 +119,14 @@ class ArrayRepositoryTest extends TestCase
$package->setType('composer-plugin'); $package->setType('composer-plugin');
$repo->addPackage($package); $repo->addPackage($package);
$this->assertSame( self::assertSame(
[['name' => 'foo', 'description' => null]], [['name' => 'foo', 'description' => null]],
$repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library') $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]], [['name' => 'foobar', 'description' => null]],
$repo->search('foo', 0, 'composer-plugin') $repo->search('foo', 0, 'composer-plugin')
); );
@ -143,7 +143,7 @@ class ArrayRepositoryTest extends TestCase
$package2->setAbandoned('bar'); $package2->setAbandoned('bar');
$repo->addPackage($package2); $repo->addPackage($package2);
$this->assertSame( self::assertSame(
[ [
['name' => 'foo1', 'description' => null, 'abandoned' => true], ['name' => 'foo1', 'description' => null, 'abandoned' => true],
['name' => 'foo2', 'description' => null, 'abandoned' => 'bar'], ['name' => 'foo2', 'description' => null, 'abandoned' => 'bar'],

View File

@ -51,14 +51,14 @@ class ArtifactRepositoryTest extends TestCase
sort($expectedPackages); sort($expectedPackages);
sort($foundPackages); sort($foundPackages);
$this->assertSame($expectedPackages, $foundPackages); self::assertSame($expectedPackages, $foundPackages);
$tarPackage = array_filter($repo->getPackages(), static function (BasePackage $package): bool { $tarPackage = array_filter($repo->getPackages(), static function (BasePackage $package): bool {
return $package->getPrettyName() === 'test/jsonInRootTarFile'; return $package->getPrettyName() === 'test/jsonInRootTarFile';
}); });
$this->assertCount(1, $tarPackage); self::assertCount(1, $tarPackage);
$tarPackage = array_pop($tarPackage); $tarPackage = array_pop($tarPackage);
$this->assertSame('tar', $tarPackage->getDistType()); self::assertSame('tar', $tarPackage->getDistType());
} }
public function testAbsoluteRepoUrlCreatesAbsoluteUrlPackages(): void public function testAbsoluteRepoUrlCreatesAbsoluteUrlPackages(): void
@ -68,7 +68,7 @@ class ArtifactRepositoryTest extends TestCase
$repo = new ArtifactRepository($coordinates, new NullIO()); $repo = new ArtifactRepository($coordinates, new NullIO());
foreach ($repo->getPackages() as $package) { 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()); $repo = new ArtifactRepository($coordinates, new NullIO());
foreach ($repo->getPackages() as $package) { foreach ($repo->getPackages() as $package) {
$this->assertSame(strpos($package->getDistUrl(), $relativePath), 0); self::assertSame(strpos($package->getDistUrl(), $relativePath), 0);
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More