1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

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
This commit is contained in:
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

@ -62,6 +62,6 @@ class FossilDriverTest extends TestCase
{
$config = new Config();
$result = FossilDriver::supports($this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $config, $url);
$this->assertEquals($assertion, $result);
self::assertEquals($assertion, $result);
}
}

View file

@ -111,12 +111,12 @@ class GitBitbucketDriverTest extends TestCase
['url' => $urls[4], 'body' => '{"date": "2016-05-17T13:19:52+00:00"}'],
], true);
$this->assertEquals(
self::assertEquals(
'main',
$driver->getRootIdentifier()
);
$this->assertEquals(
self::assertEquals(
[
'1.0.1' => '9b78a3932143497c519e49b8241083838c8ff8a1',
'1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb',
@ -124,14 +124,14 @@ class GitBitbucketDriverTest extends TestCase
$driver->getTags()
);
$this->assertEquals(
self::assertEquals(
[
'main' => '937992d19d72b5116c3e8c4a04f960e5fa270b22',
],
$driver->getBranches()
);
$this->assertEquals(
self::assertEquals(
[
'name' => 'user/repo',
'description' => 'test repo',
@ -167,9 +167,9 @@ class GitBitbucketDriverTest extends TestCase
{
$url = 'https://bitbucket.org/user/repo.git';
$this->assertEquals($url, $driver->getUrl());
self::assertEquals($url, $driver->getUrl());
$this->assertEquals(
self::assertEquals(
[
'type' => 'zip',
'url' => 'https://bitbucket.org/user/repo/get/reference.zip',
@ -179,7 +179,7 @@ class GitBitbucketDriverTest extends TestCase
$driver->getDist('reference')
);
$this->assertEquals(
self::assertEquals(
['type' => 'git', 'url' => $url, 'reference' => 'reference'],
$driver->getSource('reference')
);
@ -217,22 +217,22 @@ class GitBitbucketDriverTest extends TestCase
$driver->getRootIdentifier();
$data = $driver->getComposerInformation('main');
$this->assertIsArray($data);
$this->assertSame('https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=main', $data['support']['source']);
self::assertIsArray($data);
self::assertSame('https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=main', $data['support']['source']);
}
public function testSupports(): void
{
$this->assertTrue(
self::assertTrue(
GitBitbucketDriver::supports($this->io, $this->config, 'https://bitbucket.org/user/repo.git')
);
// should not be changed, see https://github.com/composer/composer/issues/9400
$this->assertFalse(
self::assertFalse(
GitBitbucketDriver::supports($this->io, $this->config, 'git@bitbucket.org:user/repo.git')
);
$this->assertFalse(
self::assertFalse(
GitBitbucketDriver::supports($this->io, $this->config, 'https://github.com/user/repo.git')
);
}

View file

@ -76,7 +76,7 @@ GIT;
'stdout' => $stdout,
]], true);
$this->assertSame('main', $driver->getRootIdentifier());
self::assertSame('main', $driver->getRootIdentifier());
}
public function testGetRootIdentifierFromRemote(): void
@ -109,7 +109,7 @@ GIT;
'stdout' => $stdout,
]]);
$this->assertSame('main', $driver->getRootIdentifier());
self::assertSame('main', $driver->getRootIdentifier());
}
public function testGetRootIdentifierFromLocalWithNetworkDisabled(): void
@ -134,7 +134,7 @@ GIT;
'stdout' => $stdout,
]]);
$this->assertSame('main', $driver->getRootIdentifier());
self::assertSame('main', $driver->getRootIdentifier());
}
public function testGetBranchesFilterInvalidBranchNames(): void
@ -160,7 +160,7 @@ GIT;
]]);
$branches = $driver->getBranches();
$this->assertSame([
self::assertSame([
'main' => '089681446ba44d6d9004350192486f2ceb4eaa06',
'2.2' => '12681446ba44d6d9004350192486f2ceb4eaa06',
], $branches);
@ -174,7 +174,7 @@ GIT;
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$driver = new GitDriver(['url' => 'https://example.org/acme.git'], $io, $this->config, $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock(), $process);
$this->assertNull($driver->getFileContent('file.txt', 'h'));
self::assertNull($driver->getFileContent('file.txt', 'h'));
$driver->getFileContent('file.txt', '-h');
}

View file

@ -91,18 +91,18 @@ class GitHubDriverTest extends TestCase
$gitHubDriver->initialize();
$this->setAttribute($gitHubDriver, 'tags', [$identifier => $sha]);
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
self::assertEquals('test_master', $gitHubDriver->getRootIdentifier());
$dist = $gitHubDriver->getDist($sha);
self::assertIsArray($dist);
$this->assertEquals('zip', $dist['type']);
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
$this->assertEquals('SOMESHA', $dist['reference']);
self::assertEquals('zip', $dist['type']);
self::assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
self::assertEquals('SOMESHA', $dist['reference']);
$source = $gitHubDriver->getSource($sha);
$this->assertEquals('git', $source['type']);
$this->assertEquals($repoSshUrl, $source['url']);
$this->assertEquals('SOMESHA', $source['reference']);
self::assertEquals('git', $source['type']);
self::assertEquals($repoSshUrl, $source['url']);
self::assertEquals('SOMESHA', $source['reference']);
}
public function testPublicRepository(): void
@ -134,18 +134,18 @@ class GitHubDriverTest extends TestCase
$gitHubDriver->initialize();
$this->setAttribute($gitHubDriver, 'tags', [$identifier => $sha]);
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
self::assertEquals('test_master', $gitHubDriver->getRootIdentifier());
$dist = $gitHubDriver->getDist($sha);
self::assertIsArray($dist);
$this->assertEquals('zip', $dist['type']);
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
$this->assertEquals($sha, $dist['reference']);
self::assertEquals('zip', $dist['type']);
self::assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
self::assertEquals($sha, $dist['reference']);
$source = $gitHubDriver->getSource($sha);
$this->assertEquals('git', $source['type']);
$this->assertEquals($repoUrl, $source['url']);
$this->assertEquals($sha, $source['reference']);
self::assertEquals('git', $source['type']);
self::assertEquals($repoUrl, $source['url']);
self::assertEquals($sha, $source['reference']);
}
public function testPublicRepository2(): void
@ -180,23 +180,23 @@ class GitHubDriverTest extends TestCase
$gitHubDriver->initialize();
$this->setAttribute($gitHubDriver, 'tags', [$identifier => $sha]);
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
self::assertEquals('test_master', $gitHubDriver->getRootIdentifier());
$dist = $gitHubDriver->getDist($sha);
self::assertIsArray($dist);
$this->assertEquals('zip', $dist['type']);
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
$this->assertEquals($sha, $dist['reference']);
self::assertEquals('zip', $dist['type']);
self::assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
self::assertEquals($sha, $dist['reference']);
$source = $gitHubDriver->getSource($sha);
$this->assertEquals('git', $source['type']);
$this->assertEquals($repoUrl, $source['url']);
$this->assertEquals($sha, $source['reference']);
self::assertEquals('git', $source['type']);
self::assertEquals($repoUrl, $source['url']);
self::assertEquals($sha, $source['reference']);
$data = $gitHubDriver->getComposerInformation($identifier);
$this->assertIsArray($data);
$this->assertArrayNotHasKey('abandoned', $data);
self::assertIsArray($data);
self::assertArrayNotHasKey('abandoned', $data);
}
public function testInvalidSupportData(): void
@ -233,8 +233,8 @@ class GitHubDriverTest extends TestCase
$data = $gitHubDriver->getComposerInformation($identifier);
$this->assertIsArray($data);
$this->assertSame('https://github.com/composer/packagist/tree/feature/3.2-foo', $data['support']['source']);
self::assertIsArray($data);
self::assertSame('https://github.com/composer/packagist/tree/feature/3.2-foo', $data['support']['source']);
}
public function testPublicRepositoryArchived(): void
@ -271,8 +271,8 @@ class GitHubDriverTest extends TestCase
$data = $gitHubDriver->getComposerInformation($sha);
$this->assertIsArray($data);
$this->assertTrue($data['abandoned']);
self::assertIsArray($data);
self::assertTrue($data['abandoned']);
}
public function testPrivateRepositoryNoInteraction(): void
@ -326,23 +326,23 @@ class GitHubDriverTest extends TestCase
$gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config, $httpDownloader, $process);
$gitHubDriver->initialize();
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
self::assertEquals('test_master', $gitHubDriver->getRootIdentifier());
$dist = $gitHubDriver->getDist($sha);
self::assertIsArray($dist);
$this->assertEquals('zip', $dist['type']);
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
$this->assertEquals($sha, $dist['reference']);
self::assertEquals('zip', $dist['type']);
self::assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
self::assertEquals($sha, $dist['reference']);
$source = $gitHubDriver->getSource($identifier);
$this->assertEquals('git', $source['type']);
$this->assertEquals($repoSshUrl, $source['url']);
$this->assertEquals($identifier, $source['reference']);
self::assertEquals('git', $source['type']);
self::assertEquals($repoSshUrl, $source['url']);
self::assertEquals($identifier, $source['reference']);
$source = $gitHubDriver->getSource($sha);
$this->assertEquals('git', $source['type']);
$this->assertEquals($repoSshUrl, $source['url']);
$this->assertEquals($sha, $source['reference']);
self::assertEquals('git', $source['type']);
self::assertEquals($repoSshUrl, $source['url']);
self::assertEquals($sha, $source['reference']);
}
/**
@ -384,7 +384,7 @@ class GitHubDriverTest extends TestCase
{
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->assertSame($expected, GitHubDriver::supports($io, $this->config, $repoUrl));
self::assertSame($expected, GitHubDriver::supports($io, $this->config, $repoUrl));
}
/**
@ -426,7 +426,7 @@ class GitHubDriverTest extends TestCase
$gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config, $httpDownloader, $this->getProcessExecutorMock());
$gitHubDriver->initialize();
$this->assertSame('', $gitHubDriver->getFileContent('composer.json', 'main'));
self::assertSame('', $gitHubDriver->getFileContent('composer.json', 'main'));
}
/**

View file

@ -118,10 +118,10 @@ JSON;
$driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
$this->assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
$this->assertEquals('git@gitlab.com:mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
$this->assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl());
self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
self::assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
self::assertEquals('git@gitlab.com:mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
self::assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl());
return $driver;
}
@ -158,10 +158,10 @@ JSON;
$driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
$this->assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
$this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
$this->assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl());
self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
self::assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
self::assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
self::assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl());
return $driver;
}
@ -197,10 +197,10 @@ JSON;
$driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
$this->assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
$this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
$this->assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl());
self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
self::assertEquals('mymaster', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
self::assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
self::assertEquals('https://gitlab.com/mygroup/myproject', $driver->getUrl());
return $driver;
}
@ -238,10 +238,10 @@ JSON;
$driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
$this->assertEquals('1.0.x', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
$this->assertEquals($url.'.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
$this->assertEquals($url, $driver->getUrl());
self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
self::assertEquals('1.0.x', $driver->getRootIdentifier(), 'Root identifier is the default branch in GitLab');
self::assertEquals($url.'.git', $driver->getRepositoryUrl(), 'The repository URL is the SSH one by default');
self::assertEquals($url, $driver->getUrl());
}
public function testInvalidSupportData(): void
@ -256,8 +256,8 @@ JSON;
$data = $driver->getComposerInformation('main');
$this->assertIsArray($data);
$this->assertSame('https://gitlab.com/mygroup/myproject/-/tree/main', $data['support']['source']);
self::assertIsArray($data);
self::assertSame('https://gitlab.com/mygroup/myproject/-/tree/main', $data['support']['source']);
}
public function testGetDist(): void
@ -272,7 +272,7 @@ JSON;
'shasum' => '',
];
$this->assertEquals($expected, $driver->getDist($reference));
self::assertEquals($expected, $driver->getDist($reference));
}
public function testGetSource(): void
@ -286,7 +286,7 @@ JSON;
'reference' => $reference,
];
$this->assertEquals($expected, $driver->getSource($reference));
self::assertEquals($expected, $driver->getSource($reference));
}
public function testGetSource_GivenPublicProject(): void
@ -300,7 +300,7 @@ JSON;
'reference' => $reference,
];
$this->assertEquals($expected, $driver->getSource($reference));
self::assertEquals($expected, $driver->getSource($reference));
}
public function testGetTags(): void
@ -340,8 +340,8 @@ JSON;
'v2.0.0' => '8e8f60b3ec86d63733db3bd6371117a758027ec6',
];
$this->assertEquals($expected, $driver->getTags());
$this->assertEquals($expected, $driver->getTags(), 'Tags are cached');
self::assertEquals($expected, $driver->getTags());
self::assertEquals($expected, $driver->getTags(), 'Tags are cached');
}
public function testGetPaginatedRefs(): void
@ -402,8 +402,8 @@ JSON;
'stagingdupe' => '502cffe49f136443f2059803f2e7192d1ac066cd',
];
$this->assertEquals($expected, $driver->getBranches());
$this->assertEquals($expected, $driver->getBranches(), 'Branches are cached');
self::assertEquals($expected, $driver->getBranches());
self::assertEquals($expected, $driver->getBranches(), 'Branches are cached');
}
public function testGetBranches(): void
@ -444,8 +444,8 @@ JSON;
'staging' => '502cffe49f136443f2059803f2e7192d1ac066cd',
];
$this->assertEquals($expected, $driver->getBranches());
$this->assertEquals($expected, $driver->getBranches(), 'Branches are cached');
self::assertEquals($expected, $driver->getBranches());
self::assertEquals($expected, $driver->getBranches(), 'Branches are cached');
}
/**
@ -454,7 +454,7 @@ JSON;
*/
public function testSupports(string $url, bool $expected): void
{
$this->assertSame($expected, GitLabDriver::supports($this->io, $this->config, $url));
self::assertSame($expected, GitLabDriver::supports($this->io, $this->config, $url));
}
public static function dataForTestSupports(): array
@ -510,7 +510,7 @@ JSON;
$driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
}
public function testGitlabSubGroup(): void
@ -542,7 +542,7 @@ JSON;
$driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
}
public function testGitlabSubDirectorySubGroup(): void
@ -574,7 +574,7 @@ JSON;
$driver = new GitLabDriver(['url' => $url], $this->io, $this->config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
self::assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
}
public function testForwardsOptions(): void
@ -645,7 +645,7 @@ JSON;
$config->merge(['config' => ['gitlab-protocol' => 'http']]);
$driver = new GitLabDriver(['url' => $url], $this->io, $config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'Repository URL matches config request for http not git');
self::assertEquals('https://gitlab.com/mygroup/myproject.git', $driver->getRepositoryUrl(), 'Repository URL matches config request for http not git');
}
/**

View file

@ -50,7 +50,7 @@ class HgDriverTest extends TestCase
*/
public function testSupports(string $repositoryUrl): void
{
$this->assertTrue(
self::assertTrue(
HgDriver::supports($this->io, $this->config, $repositoryUrl)
);
}
@ -93,7 +93,7 @@ HG_BOOKMARKS;
]]);
$branches = $driver->getBranches();
$this->assertSame([
self::assertSame([
'help' => 'dbf6c8acb641',
'default' => 'dbf6c8acb640',
], $branches);
@ -106,7 +106,7 @@ HG_BOOKMARKS;
$process = $this->getProcessExecutorMock();
$driver = new HgDriver(['url' => 'https://example.org/acme.git'], $this->io, $this->config, $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock(), $process);
$this->assertNull($driver->getFileContent('file.txt', 'h'));
self::assertNull($driver->getFileContent('file.txt', 'h'));
$driver->getFileContent('file.txt', '-h');
}

View file

@ -132,9 +132,9 @@ class PerforceDriverTest extends TestCase
{
$driver = new PerforceDriver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->process);
$driver->initialize();
$this->assertEquals(self::TEST_URL, $driver->getUrl());
$this->assertEquals(self::TEST_DEPOT, $driver->getDepot());
$this->assertEquals(self::TEST_BRANCH, $driver->getBranch());
self::assertEquals(self::TEST_URL, $driver->getUrl());
self::assertEquals(self::TEST_DEPOT, $driver->getDepot());
self::assertEquals(self::TEST_BRANCH, $driver->getBranch());
}
public function testInitializeLogsInAndConnectsClient(): void
@ -157,7 +157,7 @@ class PerforceDriverTest extends TestCase
$this->perforce->expects($this->any())->method('getComposerInformation')->with($this->equalTo($formatted_depot_path))->will($this->returnValue([]));
$this->driver->initialize();
$result = $this->driver->hasComposerFile($identifier);
$this->assertFalse($result);
self::assertFalse($result);
}
/**
@ -171,7 +171,7 @@ class PerforceDriverTest extends TestCase
$this->perforce->expects($this->any())->method('getComposerInformation')->with($this->equalTo($formatted_depot_path))->will($this->returnValue(['']));
$this->driver->initialize();
$result = $this->driver->hasComposerFile($identifier);
$this->assertTrue($result);
self::assertTrue($result);
}
/**
@ -182,7 +182,7 @@ class PerforceDriverTest extends TestCase
public function testSupportsReturnsFalseNoDeepCheck(): void
{
$this->expectOutputString('');
$this->assertFalse(PerforceDriver::supports($this->io, $this->config, 'existing.url'));
self::assertFalse(PerforceDriver::supports($this->io, $this->config, 'existing.url'));
}
public function testCleanup(): void

View file

@ -101,6 +101,6 @@ class SvnDriverTest extends TestCase
{
$config = new Config();
$result = SvnDriver::supports($this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $config, $url);
$this->assertEquals($assertion, $result);
self::assertEquals($assertion, $result);
}
}