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

Get rid of all the ->at() mock invocations

This commit is contained in:
Jordi Boggiano 2021-12-09 17:09:07 +01:00
parent 095c36ecf8
commit ffd62795bc
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
56 changed files with 746 additions and 921 deletions

View file

@ -58,7 +58,7 @@ class ComposerRepositoryTest extends TestCase
}
$repository
->expects($this->at(2))
->expects($this->once())
->method('createPackages')
->with($this->identicalTo($expected), $this->equalTo('root file (http://example.org/packages.json)'))
->will($this->returnValue($stubs));
@ -181,16 +181,22 @@ class ComposerRepositoryTest extends TestCase
),
);
$httpDownloader = new HttpDownloaderMock(array(
'http://example.org/packages.json' => JsonFile::encode(array('search' => '/search.json?q=%query%&type=%type%')),
'http://example.org/search.json?q=foo&type=composer-plugin' => JsonFile::encode($result),
'http://example.org/search.json?q=foo&type=library' => JsonFile::encode(array()),
));
$httpDownloader = $this->getHttpDownloaderMock();
$httpDownloader->expects(
[
['url' => 'http://example.org/packages.json', 'body' => JsonFile::encode(array('search' => '/search.json?q=%query%&type=%type%'))],
['url' => 'http://example.org/search.json?q=foo&type=composer-plugin', 'body' => JsonFile::encode($result)],
['url' => 'http://example.org/search.json?q=foo&type=library', 'body' => JsonFile::encode(array())],
],
true
);
$eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$repository = new ComposerRepository($repoConfig, new NullIO, FactoryMock::createConfig(), $httpDownloader, $eventDispatcher);
$config = FactoryMock::createConfig();
$config->merge(['config' => ['cache-read-only' => true]]);
$repository = new ComposerRepository($repoConfig, new NullIO, $config, $httpDownloader, $eventDispatcher);
$this->assertSame(
array(array('name' => 'foo', 'description' => null)),
@ -205,7 +211,7 @@ class ComposerRepositoryTest extends TestCase
public function testSearchWithAbandonedPackages()
{
$repoConfig = array(
'url' => 'http://2.example.org',
'url' => 'http://example.org',
);
$result = array(
@ -223,15 +229,22 @@ class ComposerRepositoryTest extends TestCase
),
);
$httpDownloader = new HttpDownloaderMock(array(
'http://2.example.org/packages.json' => JsonFile::encode(array('search' => '/search.json?q=%query%')),
'http://2.example.org/search.json?q=foo' => JsonFile::encode($result),
));
$httpDownloader = $this->getHttpDownloaderMock();
$httpDownloader->expects(
[
['url' => 'http://example.org/packages.json', 'body' => JsonFile::encode(array('search' => '/search.json?q=%query%'))],
['url' => 'http://example.org/search.json?q=foo', 'body' => JsonFile::encode($result)],
],
true
);
$eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$repository = new ComposerRepository($repoConfig, new NullIO, FactoryMock::createConfig(), $httpDownloader, $eventDispatcher);
$config = FactoryMock::createConfig();
$config->merge(['config' => ['cache-read-only' => true]]);
$repository = new ComposerRepository($repoConfig, new NullIO, $config, $httpDownloader, $eventDispatcher);
$this->assertSame(
array(
@ -313,15 +326,22 @@ class ComposerRepositoryTest extends TestCase
public function testGetProviderNamesWillReturnPartialPackageNames()
{
$httpDownloader = new HttpDownloaderMock(array(
'http://example.org/packages.json' => JsonFile::encode(array(
'providers-lazy-url' => '/foo/p/%package%.json',
'packages' => array('foo/bar' => array(
'dev-branch' => array('name' => 'foo/bar'),
'v1.0.0' => array('name' => 'foo/bar'),
)),
)),
));
$httpDownloader = $this->getHttpDownloaderMock();
$httpDownloader->expects(
[
[
'url' => 'http://example.org/packages.json',
'body' => JsonFile::encode(array(
'providers-lazy-url' => '/foo/p/%package%.json',
'packages' => array('foo/bar' => array(
'dev-branch' => array('name' => 'foo/bar'),
'v1.0.0' => array('name' => 'foo/bar'),
)),
)),
],
],
true
);
$repository = new ComposerRepository(
array('url' => 'http://example.org/packages.json'),