public function testSearchWithType()
 {
     $repoConfig = array('url' => 'http://example.org');
     $result = array('results' => array(array('name' => 'foo', 'description' => null)));
     $rfs = $this->getMockBuilder('Composer\\Util\\RemoteFilesystem')->disableOriginalConstructor()->getMock();
     $rfs->expects($this->at(0))->method('getContents')->with('example.org', 'http://example.org/packages.json', false)->willReturn(json_encode(array('search' => '/search.json?q=%query%&type=%type%')));
     $rfs->expects($this->at(1))->method('getContents')->with('example.org', 'http://example.org/search.json?q=foo&type=composer-plugin', false)->willReturn(json_encode($result));
     $repository = new ComposerRepository($repoConfig, new NullIO(), FactoryMock::createConfig(), null, $rfs);
     $this->assertSame(array(array('name' => 'foo', 'description' => null)), $repository->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'composer-plugin'));
     $this->assertEmpty($repository->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library'));
 }
 /**
  * @dataProvider loadDataProvider
  */
 public function testLoadData(array $expected, array $repoPackages)
 {
     $repoConfig = array('url' => 'http://example.org');
     $repository = $this->getMock('Composer\\Repository\\ComposerRepository', array('loadRootServerFile', 'createPackage'), array($repoConfig, new NullIO(), FactoryMock::createConfig()));
     $repository->expects($this->exactly(2))->method('loadRootServerFile')->will($this->returnValue($repoPackages));
     foreach ($expected as $at => $arg) {
         $stubPackage = $this->getPackage('stub/stub', '1.0.0');
         $repository->expects($this->at($at + 2))->method('createPackage')->with($this->identicalTo($arg), $this->equalTo('Composer\\Package\\CompletePackage'))->will($this->returnValue($stubPackage));
     }
     // Triggers initialization
     $packages = $repository->getPackages();
     // Final sanity check, ensure the correct number of packages were added.
     $this->assertCount(count($expected), $packages);
 }