public function testCreateCanonicalizesRootDirectory() { $config = new Config(); $rootPackageFile = new RootPackageFile(); $environment = new ProjectEnvironment(null, __DIR__ . '/../Environment', $config, $rootPackageFile); $this->assertSame(__DIR__, $environment->getRootDirectory()); }
/** * Loads the package repository for a given project. * * @param ProjectEnvironment $environment The project environment. * @param PackageFileStorage $packageFileStorage The package file storage. * * @throws FileNotFoundException If the install path of a package not exist. * @throws NoDirectoryException If the install path of a package points to a file. * @throws InvalidConfigException If a configuration file contains invalid configuration. * @throws NameConflictException If a package has the same name as another loaded package. */ public function __construct(ProjectEnvironment $environment, PackageFileStorage $packageFileStorage) { $this->environment = $environment; $this->rootDir = $environment->getRootDirectory(); $this->rootPackageFile = $environment->getRootPackageFile(); $this->packageFileStorage = $packageFileStorage; }
/** * {@inheritdoc} */ public function prepareInstallation(AssetMapping $mapping) { $glob = $mapping->getGlob(); $targetName = $mapping->getTargetName(); $resources = $this->repo->find($glob); if ($resources->isEmpty()) { throw NotInstallableException::noResourceMatches($glob); } if (!$this->installTargets->contains($targetName)) { throw NotInstallableException::targetNotFound($targetName); } $target = $this->installTargets->get($targetName); $installerName = $target->getInstallerName(); if (!$this->installerManager->hasInstallerDescriptor($installerName)) { throw NotInstallableException::installerNotFound($installerName); } $installerDescriptor = $this->installerManager->getInstallerDescriptor($installerName); $installer = $this->loadInstaller($installerDescriptor); $rootDir = $this->environment->getRootDirectory(); $params = new InstallationParams($installer, $installerDescriptor, $resources, $mapping, $target, $rootDir); $installer->validateParams($params); return $params; }
public function testListPackagesWithFormat() { $args = self::$listCommand->parseArgs(new StringArgs('--format %name%:%installer%:%install_path%:%state%')); $rootDir = $this->environment->getRootDirectory(); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<EOF vendor/root::{$rootDir}:enabled vendor/package1:spock:{$rootDir}/packages/package1:enabled vendor/package2:spock:{$rootDir}/packages/package2:enabled vendor/package3:kirk:{$rootDir}/packages/package3:not-found vendor/package4:spock:{$rootDir}/packages/package4:not-loadable EOF; $this->assertSame(0, $statusCode); $this->assertSame($expected, $this->io->fetchOutput()); $this->assertEmpty($this->io->fetchErrors()); }
/** * Creates a repository manager. * * @param ProjectEnvironment $environment * @param EditableRepository $repo * @param PackageCollection $packages * @param PackageFileStorage $packageFileStorage */ public function __construct(ProjectEnvironment $environment, EditableRepository $repo, PackageCollection $packages, PackageFileStorage $packageFileStorage) { $this->environment = $environment; $this->dispatcher = $environment->getEventDispatcher(); $this->repo = $repo; $this->config = $environment->getConfig(); $this->rootDir = $environment->getRootDirectory(); $this->rootPackage = $packages->getRootPackage(); $this->rootPackageFile = $environment->getRootPackageFile(); $this->packages = $packages; $this->packageFileStorage = $packageFileStorage; }
/** * Creates a new factory generator. * * @param ProjectEnvironment $environment The project environment. * @param GeneratorRegistry $generatorRegistry The registry providing the * generators for the services * returned by the factory. * @param ClassWriter $classWriter The writer that writes the * class to a file. * @param ServerCollection $servers The configured servers. */ public function __construct(ProjectEnvironment $environment, GeneratorRegistry $generatorRegistry, ClassWriter $classWriter, ServerCollection $servers = null) { $config = $environment->getConfig(); $this->environment = $environment; $this->rootDir = $environment->getRootDirectory(); $this->factoryInFile = Path::makeAbsolute($config->get(Config::FACTORY_IN_FILE), $this->rootDir); $this->factoryInClass = $config->get(Config::FACTORY_IN_CLASS); $this->factoryOutFile = Path::makeAbsolute($config->get(Config::FACTORY_OUT_FILE), $this->rootDir); $this->factoryOutClass = $config->get(Config::FACTORY_OUT_CLASS); $this->generatorRegistry = $generatorRegistry; $this->classWriter = $classWriter; $this->servers = $servers; }