public function testLoadPackageFileReturnsNewIfNotFound()
 {
     $packageFile = new PackageFile(null, '/path');
     $this->backend->expects($this->once())->method('exists')->with('/path')->willReturn(false);
     $this->backend->expects($this->never())->method('read');
     $this->serializer->expects($this->never())->method('unserializePackageFile');
     $this->assertEquals($packageFile, $this->storage->loadPackageFile('/path'));
 }
 /**
  * Loads the package file for the package at the given install path.
  *
  * @param string $installPath The absolute install path of the package
  *
  * @return PackageFile The loaded package file.
  */
 private function loadPackageFile($installPath)
 {
     if (!file_exists($installPath)) {
         throw FileNotFoundException::forPath($installPath);
     }
     if (!is_dir($installPath)) {
         throw new NoDirectoryException(sprintf('The path %s is a file. Expected a directory.', $installPath));
     }
     return $this->packageFileStorage->loadPackageFile($installPath . '/puli.json');
 }
Beispiel #3
0
 /**
  * Loads the package file for the package at the given install path.
  *
  * @param string $installPath The absolute install path of the package
  *
  * @return PackageFile|null The loaded package file or `null` if none
  *                          could be found.
  */
 private function loadPackageFile($installPath)
 {
     if (!file_exists($installPath)) {
         throw FileNotFoundException::forPath($installPath);
     }
     if (!is_dir($installPath)) {
         throw new NoDirectoryException(sprintf('The path %s is a file. Expected a directory.', $installPath));
     }
     try {
         return $this->packageFileStorage->loadPackageFile($installPath . '/puli.json');
     } catch (FileNotFoundException $e) {
         // Packages without package files are ok
         return null;
     }
 }
 public function testLoadPackageFile()
 {
     $packageFile = new PackageFile('vendor/package');
     $this->reader->expects($this->once())->method('readPackageFile')->with('/path')->will($this->returnValue($packageFile));
     $this->assertSame($packageFile, $this->storage->loadPackageFile('/path'));
 }