|
@@ -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')
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|