/**
  * @test
  */
 public function createReturnsAnInstanceOfTheDefaultPackageIfNoCustomPackageExists()
 {
     $packagePath = 'vfs://Packages/Some/Path/Some.Package/';
     mkdir($packagePath, 0777, TRUE);
     file_put_contents($packagePath . 'composer.json', '{"name": "some/package", "type": "flow-test"}');
     $package = $this->packageFactory->create('vfs://Packages/', 'Some/Path/Some.Package/', 'Some.Package');
     $this->assertSame('TYPO3\\Flow\\Package\\Package', get_class($package));
 }
 /**
  * Requires and registers all packages which were defined in packageStatesConfiguration
  *
  * @param array $packageStatesConfiguration
  */
 protected function registerPackagesFromConfiguration($packageStatesConfiguration)
 {
     foreach ($packageStatesConfiguration['packages'] as $composerName => $packageStateConfiguration) {
         $packagePath = isset($packageStateConfiguration['packagePath']) ? $packageStateConfiguration['packagePath'] : null;
         $packageClassInformation = isset($packageStateConfiguration['packageClassInformation']) ? $packageStateConfiguration['packageClassInformation'] : null;
         $package = $this->packageFactory->create($this->packagesBasePath, $packagePath, $packageStateConfiguration['packageKey'], $composerName, $packageStateConfiguration['autoloadConfiguration'], $packageClassInformation);
         $this->packageKeys[strtolower($package->getPackageKey())] = $package->getPackageKey();
         $this->packages[$package->getPackageKey()] = $package;
         if (isset($packageStateConfiguration['state']) && $packageStateConfiguration['state'] === self::PACKAGE_STATE_ACTIVE || $package->isProtected()) {
             $this->activePackages[$package->getPackageKey()] = $package;
         }
     }
 }
 /**
  * Requires and registers all packages which were defined in packageStatesConfiguration
  *
  * @return void
  * @throws \TYPO3\Flow\Package\Exception\CorruptPackageException
  */
 protected function registerPackagesFromConfiguration()
 {
     foreach ($this->packageStatesConfiguration['packages'] as $packageKey => $stateConfiguration) {
         $packagePath = isset($stateConfiguration['packagePath']) ? $stateConfiguration['packagePath'] : null;
         $classesPath = isset($stateConfiguration['classesPath']) ? $stateConfiguration['classesPath'] : null;
         $manifestPath = isset($stateConfiguration['manifestPath']) ? $stateConfiguration['manifestPath'] : null;
         try {
             $package = $this->packageFactory->create($this->packagesBasePath, $packagePath, $packageKey, $classesPath, $manifestPath);
         } catch (\TYPO3\Flow\Package\Exception\InvalidPackagePathException $exception) {
             $this->unregisterPackageByPackageKey($packageKey);
             $this->systemLogger->log('Package ' . $packageKey . ' could not be loaded, it has been unregistered. Error description: "' . $exception->getMessage() . '" (' . $exception->getCode() . ')', LOG_WARNING);
             continue;
         }
         $this->registerPackage($package, false);
         if (!$this->packages[$packageKey] instanceof PackageInterface) {
             throw new \TYPO3\Flow\Package\Exception\CorruptPackageException(sprintf('The package class in package "%s" does not implement PackageInterface.', $packageKey), 1300782487);
         }
         $this->packageKeys[strtolower($packageKey)] = $packageKey;
         if ($stateConfiguration['state'] === 'active') {
             $this->activePackages[$packageKey] = $this->packages[$packageKey];
         }
     }
 }