コード例 #1
0
 public function testLoadRootPackageFile()
 {
     $baseConfig = new Config();
     $packageFile = new RootPackageFile('vendor/package', null, $baseConfig);
     $this->reader->expects($this->once())->method('readRootPackageFile')->with('/path')->will($this->returnValue($packageFile));
     $this->assertSame($packageFile, $this->storage->loadRootPackageFile('/path', $baseConfig));
 }
コード例 #2
0
 /**
  * Loads a root package file from a file path.
  *
  * If the file does not exist, an empty configuration is returned.
  *
  * @param string $path       The path to the package configuration file.
  * @param Config $baseConfig The configuration that the package will inherit
  *                           its configuration values from.
  *
  * @return RootPackageFile The loaded package file.
  *
  * @throws InvalidConfigException If the file contains invalid configuration.
  */
 public function loadRootPackageFile($path, Config $baseConfig)
 {
     try {
         // Don't use file_exists() to decouple from the file system
         $packageFile = $this->reader->readRootPackageFile($path, $baseConfig);
     } catch (FileNotFoundException $e) {
         $packageFile = new RootPackageFile(null, $path, $baseConfig);
     }
     return $packageFile;
 }