mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Added --type option to search
This commit is contained in:
parent
5a3d60c0cf
commit
6a557e45b8
7 changed files with 110 additions and 11 deletions
|
@ -13,6 +13,7 @@
|
|||
namespace Composer\Test\Repository;
|
||||
|
||||
use Composer\Repository\ArrayRepository;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
use Composer\TestCase;
|
||||
|
||||
class ArrayRepositoryTest extends TestCase
|
||||
|
@ -80,4 +81,50 @@ class ArrayRepositoryTest extends TestCase
|
|||
$this->assertTrue($repo->hasPackage($this->getPackage('foo', '1')));
|
||||
$this->assertTrue($repo->hasPackage($this->getPackage('foo', '2')));
|
||||
}
|
||||
|
||||
public function testSearch()
|
||||
{
|
||||
$repo = new ArrayRepository();
|
||||
|
||||
$repo->addPackage($this->getPackage('foo', '1'));
|
||||
$repo->addPackage($this->getPackage('bar', '1'));
|
||||
|
||||
$this->assertSame(
|
||||
array(array('name' => 'foo', 'description' => null)),
|
||||
$repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT)
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
array(array('name' => 'bar', 'description' => null)),
|
||||
$repo->search('bar')
|
||||
);
|
||||
|
||||
$this->assertEmpty(
|
||||
$repo->search('foobar')
|
||||
);
|
||||
}
|
||||
|
||||
public function testSearchWithPackageType()
|
||||
{
|
||||
$repo = new ArrayRepository();
|
||||
|
||||
$repo->addPackage($this->getPackage('foo', '1', 'Composer\Package\CompletePackage'));
|
||||
$repo->addPackage($this->getPackage('bar', '1', 'Composer\Package\CompletePackage'));
|
||||
|
||||
$package = $this->getPackage('foobar', '1', 'Composer\Package\CompletePackage');
|
||||
$package->setType('composer-plugin');
|
||||
$repo->addPackage($package);
|
||||
|
||||
$this->assertSame(
|
||||
array(array('name' => 'foo', 'description' => null)),
|
||||
$repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library')
|
||||
);
|
||||
|
||||
$this->assertEmpty($repo->search('bar', RepositoryInterface::SEARCH_FULLTEXT, 'package'));
|
||||
|
||||
$this->assertSame(
|
||||
array(array('name' => 'foobar', 'description' => null)),
|
||||
$repo->search('foo', 0, 'composer-plugin')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue