コード例 #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
 public function testLoadRootPackageFileCreatesNewIfNotFound()
 {
     $baseConfig = new Config();
     $packageFile = new RootPackageFile(null, '/path', $baseConfig);
     $this->backend->expects($this->once())->method('exists')->with('/path')->willReturn(false);
     $this->backend->expects($this->never())->method('read');
     $this->serializer->expects($this->never())->method('unserializeRootPackageFile');
     $this->assertEquals($packageFile, $this->storage->loadRootPackageFile('/path', $baseConfig));
 }
コード例 #3
0
ファイル: Puli.php プロジェクト: xabbuh/manager
 /**
  * Creates the context of a Puli project.
  *
  * The home directory is read from the context variable "PULI_HOME".
  * If this variable is not set, the home directory defaults to:
  *
  *  * `$HOME/.puli` on Linux, where `$HOME` is the context variable
  *    "HOME".
  *  * `$APPDATA/Puli` on Windows, where `$APPDATA` is the context
  *    variable "APPDATA".
  *
  * If none of these variables can be found, an exception is thrown.
  *
  * A .htaccess file is put into the home directory to protect it from web
  * access.
  *
  * @param string $rootDir The path to the project.
  *
  * @return ProjectContext The project context.
  */
 private function createProjectContext($rootDir, $env)
 {
     Assert::fileExists($rootDir, 'Could not load Puli context: The root %s does not exist.');
     Assert::directory($rootDir, 'Could not load Puli context: The root %s is a file. Expected a directory.');
     $baseConfig = new DefaultConfig();
     $homeDir = self::parseHomeDirectory();
     if (null !== ($configFile = $this->loadConfigFile($homeDir, $baseConfig))) {
         $baseConfig = $configFile->getConfig();
     }
     // Create a storage without the factory manager
     $packageFileStorage = new PackageFileStorage($this->getStorage(), $this->getPackageFileSerializer());
     $rootDir = Path::canonicalize($rootDir);
     $rootFilePath = $this->rootDir . '/puli.json';
     try {
         $rootPackageFile = $packageFileStorage->loadRootPackageFile($rootFilePath, $baseConfig);
     } catch (FileNotFoundException $e) {
         $rootPackageFile = new RootPackageFile(null, $rootFilePath, $baseConfig);
     }
     $config = new EnvConfig($rootPackageFile->getConfig());
     return new ProjectContext($homeDir, $rootDir, $config, $rootPackageFile, $configFile, $this->dispatcher, $env);
 }
コード例 #4
0
ファイル: Puli.php プロジェクト: niklongstone/manager
 /**
  * Creates the environment of a Puli project.
  *
  * The home directory is read from the environment variable "PULI_HOME".
  * If this variable is not set, the home directory defaults to:
  *
  *  * `$HOME/.puli` on Linux, where `$HOME` is the environment variable
  *    "HOME".
  *  * `$APPDATA/Puli` on Windows, where `$APPDATA` is the environment
  *    variable "APPDATA".
  *
  * If none of these variables can be found, an exception is thrown.
  *
  * A .htaccess file is put into the home directory to protect it from web
  * access.
  *
  * @param string $rootDir The path to the project.
  *
  * @return ProjectEnvironment The project environment.
  */
 private function createProjectEnvironment($rootDir)
 {
     Assert::fileExists($rootDir, 'Could not load Puli environment: The root %s does not exist.');
     Assert::directory($rootDir, 'Could not load Puli environment: The root %s is a file. Expected a directory.');
     $homeDir = self::parseHomeDirectory();
     if (null !== $homeDir) {
         Assert::fileExists($homeDir, 'Could not load Puli environment: The home directory %s does not exist.');
         Assert::directory($homeDir, 'Could not load Puli environment: The home directory %s is a file. Expected a directory.');
         // Create a storage without the factory manager
         $configStorage = new ConfigFileStorage($this->getConfigFileReader(), $this->getConfigFileWriter());
         $configPath = Path::canonicalize($homeDir) . '/config.json';
         $configFile = $configStorage->loadConfigFile($configPath, new DefaultConfig());
         $baseConfig = $configFile->getConfig();
     } else {
         $configFile = null;
         $baseConfig = new DefaultConfig();
     }
     // Create a storage without the factory manager
     $packageFileStorage = new PackageFileStorage($this->getPackageFileReader(), $this->getPackageFileWriter());
     $rootDir = Path::canonicalize($rootDir);
     $rootFilePath = $this->rootDir . '/puli.json';
     $rootPackageFile = $packageFileStorage->loadRootPackageFile($rootFilePath, $baseConfig);
     $config = new EnvConfig($rootPackageFile->getConfig());
     return new ProjectEnvironment($homeDir, $rootDir, $config, $rootPackageFile, $configFile, $this->dispatcher);
 }