public function testRepositoryWrite()
 {
     $json = $this->createJsonFileMock();
     $repository = new FilesystemRepository($json);
     $json->expects($this->once())->method('read')->will($this->returnValue(array()));
     $json->expects($this->once())->method('exists')->will($this->returnValue(true));
     $json->expects($this->once())->method('write')->with(array(array('name' => 'mypkg', 'type' => 'library', 'version' => '0.1.10', 'version_normalized' => '0.1.10.0')));
     $repository->addPackage($this->getPackage('mypkg', '0.1.10'));
     $repository->write();
 }
 /**
  * @param  string                    $vendor
  * @throws \InvalidArgumentException if $vendor is not found
  * @return string
  */
 private function resolveSrc($vendor)
 {
     $src = null;
     /** @var $packages \Composer\Package\CompletePackage[] */
     $packages = $this->repository->getPackages();
     foreach ($packages as $package) {
         if ($vendor == $package->getName()) {
             $autoload = $package->getAutoload();
             $src = current($autoload['psr-0']);
             break;
         }
     }
     if (null === $src) {
         throw new \InvalidArgumentException(sprintf("Vendor \"%s\" not found", $vendor));
     }
     return $src;
 }