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

Add back abandoned key in repository search results (#10259)

This commit is contained in:
Martin Herndl 2021-11-08 10:27:45 +01:00 committed by GitHub
parent d7154c2a72
commit 5b47fa1896
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 3 deletions

View file

@ -216,6 +216,55 @@ class ComposerRepositoryTest extends TestCase
);
}
public function testSearchWithAbandonedPackages()
{
$repoConfig = array(
'url' => 'http://example.org',
);
$result = array(
'results' => array(
array(
'name' => 'foo1',
'description' => null,
'abandoned' => true,
),
array(
'name' => 'foo2',
'description' => null,
'abandoned' => 'bar',
),
),
);
$httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')
->disableOriginalConstructor()
->getMock();
$eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$httpDownloader->expects($this->at(1))
->method('get')
->with($url = 'http://example.org/packages.json')
->willReturn(new \Composer\Util\Http\Response(array('url' => $url), 200, array(), json_encode(array('search' => '/search.json?q=%query%'))));
$httpDownloader->expects($this->at(2))
->method('get')
->with($url = 'http://example.org/search.json?q=foo')
->willReturn(new \Composer\Util\Http\Response(array('url' => $url), 200, array(), json_encode($result)));
$repository = new ComposerRepository($repoConfig, new NullIO, FactoryMock::createConfig(), $httpDownloader, $eventDispatcher);
$this->assertSame(
array(
array('name' => 'foo1', 'description' => null, 'abandoned' => true),
array('name' => 'foo2', 'description' => null, 'abandoned' => 'bar'),
),
$repository->search('foo')
);
}
/**
* @dataProvider provideCanonicalizeUrlTestCases
*