From 62363bfafd5940579c9a281a13fd5145511c195d Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 29 Jul 2016 09:44:00 +0200 Subject: [PATCH 1/7] Moved the rest of Puli\Manager\Api\Package to Puli\Manager\Api\Module Did also fix the old rename of Puli => Container --- src/Handler/BindCommandHandler.php | 34 +++--- src/Handler/ConfigCommandHandler.php | 8 +- src/Handler/MapCommandHandler.php | 18 +-- src/Handler/PackageCommandHandler.php | 115 ++++++++++--------- src/Handler/PluginCommandHandler.php | 8 +- src/Handler/TypeCommandHandler.php | 16 +-- src/Handler/UpgradeCommandHandler.php | 8 +- src/Proxy/DiscoveryManagerProxy.php | 8 +- src/Proxy/RepositoryManagerProxy.php | 8 +- src/PuliApplicationConfig.php | 40 +++---- src/Util/ArgsUtil.php | 20 ++-- tests/Handler/AbstractCommandHandlerTest.php | 4 +- tests/Handler/BindCommandHandlerTest.php | 54 ++++----- tests/Handler/ConfigCommandHandlerTest.php | 6 +- tests/Handler/MapCommandHandlerTest.php | 42 +++---- tests/Handler/PackageCommandHandlerTest.php | 98 ++++++++-------- tests/Handler/PluginCommandHandlerTest.php | 6 +- tests/Handler/TypeCommandHandlerTest.php | 36 +++--- tests/Handler/UpgradeCommandHandlerTest.php | 18 +-- 19 files changed, 274 insertions(+), 273 deletions(-) diff --git a/src/Handler/BindCommandHandler.php b/src/Handler/BindCommandHandler.php index 71a909f..6a5220d 100644 --- a/src/Handler/BindCommandHandler.php +++ b/src/Handler/BindCommandHandler.php @@ -19,8 +19,8 @@ use Puli\Manager\Api\Discovery\BindingDescriptor; use Puli\Manager\Api\Discovery\BindingState; use Puli\Manager\Api\Discovery\DiscoveryManager; -use Puli\Manager\Api\Package\PackageCollection; -use Puli\Manager\Api\Package\RootPackage; +use Puli\Manager\Api\Module\ModuleList; +use Puli\Manager\Api\Module\RootModule; use RuntimeException; use Webmozart\Console\Api\Args\Args; use Webmozart\Console\Api\IO\IO; @@ -43,9 +43,9 @@ class BindCommandHandler private $discoveryManager; /** - * @var PackageCollection + * @var ModuleList */ - private $packages; + private $modules; /** * @var string @@ -56,12 +56,12 @@ class BindCommandHandler * Creates the handler. * * @param DiscoveryManager $discoveryManager The discovery manager. - * @param PackageCollection $packages The loaded packages. + * @param ModuleList $modules The loaded packages. */ - public function __construct(DiscoveryManager $discoveryManager, PackageCollection $packages) + public function __construct(DiscoveryManager $discoveryManager, ModuleList $modules) { $this->discoveryManager = $discoveryManager; - $this->packages = $packages; + $this->modules = $modules; } /** @@ -74,7 +74,7 @@ public function __construct(DiscoveryManager $discoveryManager, PackageCollectio */ public function handleList(Args $args, IO $io) { - $packageNames = ArgsUtil::getPackageNames($args, $this->packages); + $packageNames = ArgsUtil::getPackageNames($args, $this->modules); $bindingStates = $this->getBindingStates($args); $printBindingState = count($bindingStates) > 1; @@ -88,7 +88,7 @@ public function handleList(Args $args, IO $io) $bindingStatePrinted = !$printBindingState; foreach ($packageNames as $packageName) { - $expr = Expr::method('getContainingPackage', Expr::method('getName', Expr::same($packageName))) + $expr = Expr::method('getContainingModule', Expr::method('getName', Expr::same($packageName))) ->andMethod('getState', Expr::same($bindingState)); $descriptors = $this->discoveryManager->findBindingDescriptors($expr); @@ -181,10 +181,10 @@ public function handleUpdate(Args $args) $descriptorToUpdate = $this->getBindingByUuidPrefix($args->getArgument('uuid')); $bindingToUpdate = $descriptorToUpdate->getBinding(); - if (!$descriptorToUpdate->getContainingPackage() instanceof RootPackage) { + if (!$descriptorToUpdate->getContainingModule() instanceof RootModule) { throw new RuntimeException(sprintf( 'Can only update bindings in the package "%s".', - $this->packages->getRootPackageName() + $this->modules->getRootModuleName() )); } @@ -221,10 +221,10 @@ public function handleDelete(Args $args) { $bindingToRemove = $this->getBindingByUuidPrefix($args->getArgument('uuid')); - if (!$bindingToRemove->getContainingPackage() instanceof RootPackage) { + if (!$bindingToRemove->getContainingModule() instanceof RootModule) { throw new RuntimeException(sprintf( 'Can only delete bindings from the package "%s".', - $this->packages->getRootPackageName() + $this->modules->getRootModuleName() )); } @@ -244,10 +244,10 @@ public function handleEnable(Args $args) { $bindingToEnable = $this->getBindingByUuidPrefix($args->getArgument('uuid')); - if ($bindingToEnable->getContainingPackage() instanceof RootPackage) { + if ($bindingToEnable->getContainingModule() instanceof RootModule) { throw new RuntimeException(sprintf( 'Cannot enable bindings in the package "%s".', - $bindingToEnable->getContainingPackage()->getName() + $bindingToEnable->getContainingModule()->getName() )); } @@ -267,10 +267,10 @@ public function handleDisable(Args $args) { $bindingToDisable = $this->getBindingByUuidPrefix($args->getArgument('uuid')); - if ($bindingToDisable->getContainingPackage() instanceof RootPackage) { + if ($bindingToDisable->getContainingModule() instanceof RootModule) { throw new RuntimeException(sprintf( 'Cannot disable bindings in the package "%s".', - $bindingToDisable->getContainingPackage()->getName() + $bindingToDisable->getContainingModule()->getName() )); } diff --git a/src/Handler/ConfigCommandHandler.php b/src/Handler/ConfigCommandHandler.php index 81e32e0..0e348ef 100644 --- a/src/Handler/ConfigCommandHandler.php +++ b/src/Handler/ConfigCommandHandler.php @@ -13,7 +13,7 @@ use Puli\Cli\Style\PuliTableStyle; use Puli\Cli\Util\StringUtil; -use Puli\Manager\Api\Package\RootPackageFileManager; +use Puli\Manager\Api\Module\RootModuleFileManager; use Webmozart\Console\Api\Args\Args; use Webmozart\Console\Api\IO\IO; use Webmozart\Console\UI\Component\Table; @@ -28,16 +28,16 @@ class ConfigCommandHandler { /** - * @var RootPackageFileManager + * @var RootModuleFileManager */ private $manager; /** * Creates the handler. * - * @param RootPackageFileManager $manager The root package file manager. + * @param RootModuleFileManager $manager The root package file manager. */ - public function __construct(RootPackageFileManager $manager) + public function __construct(RootModuleFileManager $manager) { $this->manager = $manager; } diff --git a/src/Handler/MapCommandHandler.php b/src/Handler/MapCommandHandler.php index cc30244..ba87c1d 100644 --- a/src/Handler/MapCommandHandler.php +++ b/src/Handler/MapCommandHandler.php @@ -13,7 +13,7 @@ use Puli\Cli\Style\PuliTableStyle; use Puli\Cli\Util\ArgsUtil; -use Puli\Manager\Api\Package\PackageCollection; +use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Repository\PathConflict; use Puli\Manager\Api\Repository\PathMapping; use Puli\Manager\Api\Repository\PathMappingState; @@ -40,9 +40,9 @@ class MapCommandHandler private $repoManager; /** - * @var PackageCollection + * @var ModuleList */ - private $packages; + private $modules; /** * @var string @@ -53,12 +53,12 @@ class MapCommandHandler * Creates the handler. * * @param RepositoryManager $repoManager The repository manager. - * @param PackageCollection $packages The loaded packages. + * @param ModuleList $modules The loaded packages. */ - public function __construct(RepositoryManager $repoManager, PackageCollection $packages) + public function __construct(RepositoryManager $repoManager, ModuleList $modules) { $this->repoManager = $repoManager; - $this->packages = $packages; + $this->modules = $modules; } /** @@ -71,7 +71,7 @@ public function __construct(RepositoryManager $repoManager, PackageCollection $p */ public function handleList(Args $args, IO $io) { - $packageNames = ArgsUtil::getPackageNames($args, $this->packages); + $packageNames = ArgsUtil::getPackageNames($args, $this->modules); $states = $this->getPathMappingStates($args); $printState = count($states) > 1; @@ -223,7 +223,7 @@ public function handleDelete(Args $args) throw new RuntimeException(sprintf( 'The path "%s" is not mapped in the package "%s".', $repositoryPath, - $this->packages->getRootPackageName() + $this->modules->getRootModuleName() )); } @@ -314,7 +314,7 @@ private function printConflictTable(IO $io, array $mappings, $indentation = 0) foreach ($conflict->getMappings() as $mapping) { $table->addRow(array( - ''.$mapping->getContainingPackage()->getName().'', + ''.$mapping->getContainingModule()->getName().'', ''.$mapping->getRepositoryPath().'', ''.implode(', ', $mapping->getPathReferences()).'', )); diff --git a/src/Handler/PackageCommandHandler.php b/src/Handler/PackageCommandHandler.php index 11d1772..43f8987 100644 --- a/src/Handler/PackageCommandHandler.php +++ b/src/Handler/PackageCommandHandler.php @@ -14,10 +14,10 @@ use Puli\Cli\Style\PuliTableStyle; use Puli\Cli\Util\StringUtil; use Puli\Manager\Api\Environment; -use Puli\Manager\Api\Package\Package; -use Puli\Manager\Api\Package\PackageCollection; -use Puli\Manager\Api\Package\PackageManager; -use Puli\Manager\Api\Package\PackageState; +use Puli\Manager\Api\Module\Module; +use Puli\Manager\Api\Module\ModuleList; +use Puli\Manager\Api\Module\ModuleManager; +use Puli\Manager\Api\Module\ModuleState; use RuntimeException; use Webmozart\Console\Api\Args\Args; use Webmozart\Console\Api\IO\IO; @@ -38,24 +38,24 @@ class PackageCommandHandler * @var array */ private static $stateStrings = array( - PackageState::ENABLED => 'enabled', - PackageState::NOT_FOUND => 'not-found', - PackageState::NOT_LOADABLE => 'not-loadable', + ModuleState::ENABLED => 'enabled', + ModuleState::NOT_FOUND => 'not-found', + ModuleState::NOT_LOADABLE => 'not-loadable', ); /** - * @var PackageManager + * @var ModuleManager */ - private $packageManager; + private $moduleManager; /** * Creates the handler. * - * @param PackageManager $packageManager The package manager. + * @param ModuleManager $moduleManager The package manager. */ - public function __construct(PackageManager $packageManager) + public function __construct(ModuleManager $moduleManager) { - $this->packageManager = $packageManager; + $this->moduleManager = $moduleManager; } /** @@ -93,7 +93,7 @@ public function handleInstall(Args $args) $installer = $args->getOption('installer'); $env = $args->isOptionSet('dev') ? Environment::DEV : Environment::PROD; - $this->packageManager->installPackage($installPath, $packageName, $installer, $env); + $this->moduleManager->installModule($installPath, $packageName, $installer, $env); return 0; } @@ -110,7 +110,7 @@ public function handleRename(Args $args) $packageName = $args->getArgument('name'); $newName = $args->getArgument('new-name'); - $this->packageManager->renamePackage($packageName, $newName); + $this->moduleManager->renameModule($packageName, $newName); return 0; } @@ -126,14 +126,14 @@ public function handleDelete(Args $args) { $packageName = $args->getArgument('name'); - if (!$this->packageManager->hasPackage($packageName)) { + if (!$this->moduleManager->hasModule($packageName)) { throw new RuntimeException(sprintf( 'The package "%s" is not installed.', $packageName )); } - $this->packageManager->removePackage($packageName); + $this->moduleManager->removeModule($packageName); return 0; } @@ -148,11 +148,11 @@ public function handleDelete(Args $args) */ public function handleClean(Args $args, IO $io) { - $expr = Expr::method('getState', Expr::same(PackageState::NOT_FOUND)); + $expr = Expr::method('getState', Expr::same(ModuleState::NOT_FOUND)); - foreach ($this->packageManager->findPackages($expr) as $package) { - $io->writeLine('Removing '.$package->getName()); - $this->packageManager->removePackage($package->getName()); + foreach ($this->moduleManager->findModules($expr) as $module) { + $io->writeLine('Removing '.$module->getName()); + $this->moduleManager->removeModule($module->getName()); } return 0; @@ -164,25 +164,25 @@ public function handleClean(Args $args, IO $io) * * @param Args $args The console arguments. * - * @return int[] A list of {@link PackageState} constants. + * @return int[] A list of {@link ModuleState} constants. */ private function getSelectedStates(Args $args) { $states = array(); if ($args->isOptionSet('enabled')) { - $states[] = PackageState::ENABLED; + $states[] = ModuleState::ENABLED; } if ($args->isOptionSet('not-found')) { - $states[] = PackageState::NOT_FOUND; + $states[] = ModuleState::NOT_FOUND; } if ($args->isOptionSet('not-loadable')) { - $states[] = PackageState::NOT_LOADABLE; + $states[] = ModuleState::NOT_LOADABLE; } - return $states ?: PackageState::all(); + return $states ?: ModuleState::all(); } /** @@ -191,7 +191,7 @@ private function getSelectedStates(Args $args) * * @param Args $args The console arguments. * - * @return PackageCollection The packages. + * @return ModuleList The packages. */ private function getSelectedPackages(Args $args) { @@ -199,7 +199,7 @@ private function getSelectedPackages(Args $args) $expr = Expr::true(); $envs = array(); - if ($states !== PackageState::all()) { + if ($states !== ModuleState::all()) { $expr = $expr->andMethod('getState', Expr::in($states)); } @@ -219,23 +219,23 @@ private function getSelectedPackages(Args $args) $expr = $expr->andMethod('getInstallInfo', Expr::method('getEnvironment', Expr::in($envs))); } - return $this->packageManager->findPackages($expr); + return $this->moduleManager->findModules($expr); } /** * Prints packages with intermediate headers for the package states. * * @param IO $io The I/O. - * @param PackageCollection $packages The packages to print. + * @param ModuleList $modules The packages to print. * @param int[] $states The states to print. */ - private function printPackagesByState(IO $io, PackageCollection $packages, array $states) + private function printPackagesByState(IO $io, ModuleList $modules, array $states) { $printStates = count($states) > 1; foreach ($states as $state) { - $filteredPackages = array_filter($packages->toArray(), function (Package $package) use ($state) { - return $state === $package->getState(); + $filteredPackages = array_filter($modules->toArray(), function (Module $module) use ($state) { + return $state === $module->getState(); }); if (0 === count($filteredPackages)) { @@ -243,13 +243,13 @@ private function printPackagesByState(IO $io, PackageCollection $packages, array } if ($printStates) { - $this->printPackageState($io, $state); + $this->printModuleState($io, $state); } - if (PackageState::NOT_LOADABLE === $state) { + if (ModuleState::NOT_LOADABLE === $state) { $this->printNotLoadablePackages($io, $filteredPackages, $printStates); } else { - $styleTag = PackageState::ENABLED === $state ? null : 'bad'; + $styleTag = ModuleState::ENABLED === $state ? null : 'bad'; $this->printPackageTable($io, $filteredPackages, $styleTag, $printStates); } @@ -263,19 +263,20 @@ private function printPackagesByState(IO $io, PackageCollection $packages, array * Prints packages using the given format. * * @param IO $io The I/O. - * @param PackageCollection $packages The packages to print. + * @param ModuleList $modules The packages to print. * @param string $format The format string. */ - private function printPackagesWithFormat(IO $io, PackageCollection $packages, $format) + private function printPackagesWithFormat(IO $io, ModuleList $modules, $format) { - foreach ($packages as $package) { - $installInfo = $package->getInstallInfo(); + /** @var Module $module */ + foreach ($modules as $module) { + $installInfo = $module->getInstallInfo(); $io->writeLine(strtr($format, array( - '%name%' => $package->getName(), + '%name%' => $module->getName(), '%installer%' => $installInfo ? $installInfo->getInstallerName() : '', - '%install_path%' => $package->getInstallPath(), - '%state%' => self::$stateStrings[$package->getState()], + '%install_path%' => $module->getInstallPath(), + '%state%' => self::$stateStrings[$module->getState()], '%env%' => $installInfo ? $installInfo->getEnvironment() : Environment::PROD, ))); } @@ -285,23 +286,23 @@ private function printPackagesWithFormat(IO $io, PackageCollection $packages, $f * Prints the heading for a given package state. * * @param IO $io The I/O. - * @param int $packageState The {@link PackageState} constant. + * @param int $ModuleState The {@link ModuleState} constant. */ - private function printPackageState(IO $io, $packageState) + private function printModuleState(IO $io, $ModuleState) { - switch ($packageState) { - case PackageState::ENABLED: + switch ($ModuleState) { + case ModuleState::ENABLED: $io->writeLine('The following packages are currently enabled:'); $io->writeLine(''); return; - case PackageState::NOT_FOUND: + case ModuleState::NOT_FOUND: $io->writeLine('The following packages could not be found:'); $io->writeLine(' (use "puli package --clean" to remove)'); $io->writeLine(''); return; - case PackageState::NOT_LOADABLE: + case ModuleState::NOT_LOADABLE: $io->writeLine('The following packages could not be loaded:'); $io->writeLine(''); @@ -313,12 +314,12 @@ private function printPackageState(IO $io, $packageState) * Prints a list of packages in a table. * * @param IO $io The I/O. - * @param Package[] $packages The packages. + * @param Module[] $modules The packages. * @param string|null $styleTag The tag used to style the output. If `null`, * the default colors are used. * @param bool $indent Whether to indent the output. */ - private function printPackageTable(IO $io, array $packages, $styleTag = null, $indent = false) + private function printPackageTable(IO $io, array $modules, $styleTag = null, $indent = false) { $table = new Table(PuliTableStyle::borderless()); $table->setHeaderRow(array('Package Name', 'Installer', 'Env', 'Install Path')); @@ -327,9 +328,9 @@ private function printPackageTable(IO $io, array $packages, $styleTag = null, $i $envTag = $styleTag ?: 'c1'; $pathTag = $styleTag ?: 'c2'; - ksort($packages); + ksort($modules); - foreach ($packages as $package) { + foreach ($modules as $package) { $packageName = $package->getName(); $installInfo = $package->getInstallInfo(); $installPath = $installInfo ? $installInfo->getInstallPath() : '.'; @@ -351,18 +352,18 @@ private function printPackageTable(IO $io, array $packages, $styleTag = null, $i * Prints not-loadable packages in a table. * * @param IO $io The I/O. - * @param Package[] $packages The not-loadable packages. + * @param Module[] $modules The not-loadable packages. * @param bool $indent Whether to indent the output. */ - private function printNotLoadablePackages(IO $io, array $packages, $indent = false) + private function printNotLoadablePackages(IO $io, array $modules, $indent = false) { - $rootDir = $this->packageManager->getContext()->getRootDirectory(); + $rootDir = $this->moduleManager->getContext()->getRootDirectory(); $table = new Table(PuliTableStyle::borderless()); $table->setHeaderRow(array('Package Name', 'Error')); - ksort($packages); + ksort($modules); - foreach ($packages as $package) { + foreach ($modules as $package) { $packageName = $package->getName(); $loadErrors = $package->getLoadErrors(); $errorMessage = ''; diff --git a/src/Handler/PluginCommandHandler.php b/src/Handler/PluginCommandHandler.php index 227979e..c915d91 100644 --- a/src/Handler/PluginCommandHandler.php +++ b/src/Handler/PluginCommandHandler.php @@ -11,7 +11,7 @@ namespace Puli\Cli\Handler; -use Puli\Manager\Api\Package\RootPackageFileManager; +use Puli\Manager\Api\Module\RootModuleFileManager; use RuntimeException; use Webmozart\Console\Api\Args\Args; use Webmozart\Console\Api\IO\IO; @@ -26,16 +26,16 @@ class PluginCommandHandler { /** - * @var RootPackageFileManager + * @var RootModuleFileManager */ private $manager; /** * Creates the handler. * - * @param RootPackageFileManager $manager The root package file manager. + * @param RootModuleFileManager $manager The root package file manager. */ - public function __construct(RootPackageFileManager $manager) + public function __construct(RootModuleFileManager $manager) { $this->manager = $manager; } diff --git a/src/Handler/TypeCommandHandler.php b/src/Handler/TypeCommandHandler.php index 32fcaf1..b85ba28 100644 --- a/src/Handler/TypeCommandHandler.php +++ b/src/Handler/TypeCommandHandler.php @@ -19,7 +19,7 @@ use Puli\Manager\Api\Discovery\BindingTypeDescriptor; use Puli\Manager\Api\Discovery\BindingTypeState; use Puli\Manager\Api\Discovery\DiscoveryManager; -use Puli\Manager\Api\Package\PackageCollection; +use Puli\Manager\Api\Module\ModuleList; use RuntimeException; use Webmozart\Console\Api\Args\Args; use Webmozart\Console\Api\IO\IO; @@ -41,20 +41,20 @@ class TypeCommandHandler private $discoveryManager; /** - * @var PackageCollection + * @var ModuleList */ - private $packages; + private $modules; /** * Creates the handler. * * @param DiscoveryManager $discoveryManager The discovery manager. - * @param PackageCollection $packages The loaded packages. + * @param ModuleList $modules The loaded packages. */ - public function __construct(DiscoveryManager $discoveryManager, PackageCollection $packages) + public function __construct(DiscoveryManager $discoveryManager, ModuleList $modules) { $this->discoveryManager = $discoveryManager; - $this->packages = $packages; + $this->modules = $modules; } /** @@ -67,7 +67,7 @@ public function __construct(DiscoveryManager $discoveryManager, PackageCollectio */ public function handleList(Args $args, IO $io) { - $packageNames = ArgsUtil::getPackageNames($args, $this->packages); + $packageNames = ArgsUtil::getPackageNames($args, $this->modules); $states = $this->getBindingTypeStates($args); $printStates = count($states) > 1; @@ -205,7 +205,7 @@ public function handleDelete(Args $args) throw new RuntimeException(sprintf( 'The type "%s" does not exist in the package "%s".', $typeName, - $this->packages->getRootPackageName() + $this->modules->getRootModuleName() )); } diff --git a/src/Handler/UpgradeCommandHandler.php b/src/Handler/UpgradeCommandHandler.php index 8433555..287ad09 100644 --- a/src/Handler/UpgradeCommandHandler.php +++ b/src/Handler/UpgradeCommandHandler.php @@ -11,7 +11,7 @@ namespace Puli\Cli\Handler; -use Puli\Manager\Api\Package\RootPackageFileManager; +use Puli\Manager\Api\Module\RootModuleFileManager; use Webmozart\Console\Api\Args\Args; use Webmozart\Console\Api\IO\IO; @@ -25,17 +25,17 @@ class UpgradeCommandHandler { /** - * @var RootPackageFileManager + * @var RootModuleFileManager */ private $packageFileManager; /** * Creates the command handler. * - * @param RootPackageFileManager $packageFileManager The manager of the + * @param RootModuleFileManager $packageFileManager The manager of the * puli.json file. */ - public function __construct(RootPackageFileManager $packageFileManager) + public function __construct(RootModuleFileManager $packageFileManager) { $this->packageFileManager = $packageFileManager; } diff --git a/src/Proxy/DiscoveryManagerProxy.php b/src/Proxy/DiscoveryManagerProxy.php index 5f0b330..be13409 100644 --- a/src/Proxy/DiscoveryManagerProxy.php +++ b/src/Proxy/DiscoveryManagerProxy.php @@ -14,7 +14,7 @@ use Puli\Manager\Api\Discovery\BindingDescriptor; use Puli\Manager\Api\Discovery\BindingTypeDescriptor; use Puli\Manager\Api\Discovery\DiscoveryManager; -use Puli\Manager\Api\Puli; +use Puli\Manager\Api\Container; use Rhumsaa\Uuid\Uuid; use Webmozart\Expression\Expression; @@ -28,17 +28,17 @@ class DiscoveryManagerProxy implements DiscoveryManager { /** - * @var Puli + * @var Container */ private $puli; /** * Creates the proxy. * - * @param Puli $puli The service locator to fetch the actual discovery + * @param Container $puli The service locator to fetch the actual discovery * manager from. */ - public function __construct(Puli $puli) + public function __construct(Container $puli) { $this->puli = $puli; } diff --git a/src/Proxy/RepositoryManagerProxy.php b/src/Proxy/RepositoryManagerProxy.php index 1d83971..3ad781f 100644 --- a/src/Proxy/RepositoryManagerProxy.php +++ b/src/Proxy/RepositoryManagerProxy.php @@ -11,7 +11,7 @@ namespace Puli\Cli\Proxy; -use Puli\Manager\Api\Puli; +use Puli\Manager\Api\Container; use Puli\Manager\Api\Repository\PathMapping; use Puli\Manager\Api\Repository\RepositoryManager; use Webmozart\Expression\Expression; @@ -26,17 +26,17 @@ class RepositoryManagerProxy implements RepositoryManager { /** - * @var Puli + * @var Container */ private $puli; /** * Creates the proxy. * - * @param Puli $puli The service locator to fetch the actual repository + * @param Container $puli The service locator to fetch the actual repository * manager from. */ - public function __construct(Puli $puli) + public function __construct(Container $puli) { $this->puli = $puli; } diff --git a/src/PuliApplicationConfig.php b/src/PuliApplicationConfig.php index 6471cbf..20f6af8 100644 --- a/src/PuliApplicationConfig.php +++ b/src/PuliApplicationConfig.php @@ -31,9 +31,9 @@ use Puli\Cli\Proxy\DiscoveryManagerProxy; use Puli\Cli\Proxy\RepositoryManagerProxy; use Puli\Manager\Api\Context\ProjectContext; -use Puli\Manager\Api\Package\InstallInfo; -use Puli\Manager\Api\Package\PackageFile; -use Puli\Manager\Api\Puli; +use Puli\Manager\Api\Module\InstallInfo; +use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Container; use Puli\Manager\Api\Server\Server; use Webmozart\Console\Api\Args\Format\Argument; use Webmozart\Console\Api\Args\Format\Option; @@ -58,19 +58,19 @@ class PuliApplicationConfig extends DefaultApplicationConfig const VERSION = '@package_version@'; /** - * @var Puli + * @var Container */ private $puli; /** * Creates the configuration. * - * @param Puli $puli The Puli service container. + * @param Container $puli The Puli service container. */ - public function __construct(Puli $puli = null) + public function __construct(Container $puli = null) { // Start Puli already so that plugins can change the CLI configuration - $this->puli = $puli ?: new Puli(getcwd()); + $this->puli = $puli ?: new Container(getcwd()); if (!$this->puli->isStarted()) { $this->puli->start(); @@ -114,21 +114,21 @@ protected function configure() ConsoleEvents::PRE_HANDLE, function (PreHandleEvent $event) use ($context) { $io = $event->getIO(); - $packageFile = $context->getRootPackageFile(); + $moduleFile = $context->getRootModuleFile(); // Don't show warning for "upgrade" command if ('upgrade' === $event->getCommand()->getName()) { return; } - if (version_compare($packageFile->getVersion(), PackageFile::DEFAULT_VERSION, '<')) { + if (version_compare($moduleFile->getVersion(), ModuleFile::DEFAULT_VERSION, '<')) { $io->errorLine(sprintf( 'Warning: Your puli.json file has version %s, '. 'but the latest version is %s. Run "puli upgrade" to '. 'upgrade to %s.', - $packageFile->getVersion(), - PackageFile::DEFAULT_VERSION, - PackageFile::DEFAULT_VERSION + $moduleFile->getVersion(), + ModuleFile::DEFAULT_VERSION, + ModuleFile::DEFAULT_VERSION )); } } @@ -141,7 +141,7 @@ function (PreHandleEvent $event) use ($context) { ->setHandler(function () use ($puli) { return new BindCommandHandler( $puli->getDiscoveryManager(), - $puli->getPackageManager()->getPackages() + $puli->getModuleManager()->getModules() ); }) @@ -234,7 +234,7 @@ function (PreHandleEvent $event) use ($context) { ->beginCommand('config') ->setDescription('Display and modify configuration values') ->setHandler(function () use ($puli) { - return new ConfigCommandHandler($puli->getRootPackageFileManager()); + return new ConfigCommandHandler($puli->getRootModuleFileManager()); }) ->beginSubCommand('list') @@ -328,7 +328,7 @@ function (PreHandleEvent $event) use ($context) { ->setHandler(function () use ($puli) { return new MapCommandHandler( $puli->getRepositoryManager(), - $puli->getPackageManager()->getPackages() + $puli->getModuleManager()->getModules() ); }) @@ -371,7 +371,7 @@ function (PreHandleEvent $event) use ($context) { ->beginCommand('package') ->setDescription('Display the installed packages') ->setHandler(function () use ($puli) { - return new PackageCommandHandler($puli->getPackageManager()); + return new PackageCommandHandler($puli->getModuleManager()); }) ->beginOptionCommand('install', 'i') @@ -415,7 +415,7 @@ function (PreHandleEvent $event) use ($context) { ->beginCommand('plugin') ->setDescription('Manage the installed Puli plugins') ->setHandler(function () use ($puli) { - return new PluginCommandHandler($puli->getRootPackageFileManager()); + return new PluginCommandHandler($puli->getRootModuleFileManager()); }) ->beginOptionCommand('install', 'i') @@ -547,7 +547,7 @@ function (PreHandleEvent $event) use ($context) { ->setHandler(function () use ($puli) { return new TypeCommandHandler( $puli->getDiscoveryManager(), - $puli->getPackageManager()->getPackages() + $puli->getModuleManager()->getModules() ); }) @@ -589,9 +589,9 @@ function (PreHandleEvent $event) use ($context) { $this ->beginCommand('upgrade') ->setDescription('Upgrades puli.json to the newest version') - ->addArgument('version', Argument::OPTIONAL, 'The version to upgrade/downgrade to', PackageFile::DEFAULT_VERSION) + ->addArgument('version', Argument::OPTIONAL, 'The version to upgrade/downgrade to', ModuleFile::DEFAULT_VERSION) ->setHandler(function () use ($puli) { - return new UpgradeCommandHandler($puli->getRootPackageFileManager()); + return new UpgradeCommandHandler($puli->getRootModuleFileManager()); }) ->end() ; diff --git a/src/Util/ArgsUtil.php b/src/Util/ArgsUtil.php index 4437dea..523a1ed 100644 --- a/src/Util/ArgsUtil.php +++ b/src/Util/ArgsUtil.php @@ -11,7 +11,7 @@ namespace Puli\Cli\Util; -use Puli\Manager\Api\Package\PackageCollection; +use Puli\Manager\Api\Module\ModuleList; use Webmozart\Console\Api\Args\Args; /** @@ -27,43 +27,43 @@ class ArgsUtil * Returns the packages selected in the console arguments. * * @param Args $args The console arguments. - * @param PackageCollection $packages The available packages. + * @param ModuleList $packages The available packages. * * @return string[] The package names. */ - public static function getPackageNames(Args $args, PackageCollection $packages) + public static function getPackageNames(Args $args, ModuleList $packages) { // Display all packages if "all" is set if ($args->isOptionSet('all')) { - return $packages->getPackageNames(); + return $packages->getModuleNames(); } $packageNames = array(); if ($args->isOptionSet('root')) { - $packageNames[] = $packages->getRootPackage()->getName(); + $packageNames[] = $packages->getRootModuleName(); } foreach ($args->getOption('package') as $packageName) { $packageNames[] = $packageName; } - return $packageNames ?: $packages->getPackageNames(); + return $packageNames ?: $packages->getModuleNames(); } /** * Returns the non-root packages selected in the console arguments. * * @param Args $args The console arguments. - * @param PackageCollection $packages The available packages. + * @param ModuleList $packages The available packages. * * @return string[] The package names. */ - public static function getPackageNamesWithoutRoot(Args $args, PackageCollection $packages) + public static function getPackageNamesWithoutRoot(Args $args, ModuleList $packages) { // Display all packages if "all" is set if ($args->isOptionSet('all')) { - return $packages->getInstalledPackageNames(); + return $packages->getInstalledModuleNames(); } $packageNames = array(); @@ -72,7 +72,7 @@ public static function getPackageNamesWithoutRoot(Args $args, PackageCollection $packageNames[] = $packageName; } - return $packageNames ?: $packages->getInstalledPackageNames(); + return $packageNames ?: $packages->getInstalledModuleNames(); } private function __construct() diff --git a/tests/Handler/AbstractCommandHandlerTest.php b/tests/Handler/AbstractCommandHandlerTest.php index b680cb5..8ebd8f1 100644 --- a/tests/Handler/AbstractCommandHandlerTest.php +++ b/tests/Handler/AbstractCommandHandlerTest.php @@ -14,7 +14,7 @@ use PHPUnit_Framework_TestCase; use Puli\Cli\PuliApplicationConfig; use Puli\Cli\Tests\Handler\Util\NormalizedLineEndingsIO; -use Puli\Manager\Api\Puli; +use Puli\Manager\Api\Container; use Webmozart\Console\Api\Application\Application; use Webmozart\Console\Api\Formatter\Formatter; use Webmozart\Console\ConsoleApplication; @@ -51,7 +51,7 @@ abstract class AbstractCommandHandlerTest extends PHPUnit_Framework_TestCase public static function setUpBeforeClass() { self::$tempDir = TestUtil::makeTempDir('puli-cli', __CLASS__); - self::$application = new ConsoleApplication(new PuliApplicationConfig(new Puli(self::$tempDir))); + self::$application = new ConsoleApplication(new PuliApplicationConfig(new Container(self::$tempDir))); self::$formatter = new PlainFormatter(self::$application->getConfig()->getStyleSet()); } diff --git a/tests/Handler/BindCommandHandlerTest.php b/tests/Handler/BindCommandHandlerTest.php index b9f3a7d..c99c822 100644 --- a/tests/Handler/BindCommandHandlerTest.php +++ b/tests/Handler/BindCommandHandlerTest.php @@ -21,11 +21,11 @@ use Puli\Manager\Api\Discovery\BindingDescriptor; use Puli\Manager\Api\Discovery\BindingState; use Puli\Manager\Api\Discovery\DiscoveryManager; -use Puli\Manager\Api\Package\Package; -use Puli\Manager\Api\Package\PackageCollection; -use Puli\Manager\Api\Package\PackageFile; -use Puli\Manager\Api\Package\RootPackage; -use Puli\Manager\Api\Package\RootPackageFile; +use Puli\Manager\Api\Module\Module; +use Puli\Manager\Api\Module\ModuleList; +use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\RootModule; +use Puli\Manager\Api\Module\RootModuleFile; use Rhumsaa\Uuid\Uuid; use Webmozart\Console\Api\Command\Command; use Webmozart\Console\Args\StringArgs; @@ -95,9 +95,9 @@ class BindCommandHandlerTest extends AbstractCommandHandlerTest private $discoveryManager; /** - * @var PackageCollection + * @var ModuleList */ - private $packages; + private $modules; /** * @var BindCommandHandler @@ -121,12 +121,12 @@ protected function setUp() parent::setUp(); $this->discoveryManager = $this->getMock('Puli\Manager\Api\Discovery\DiscoveryManager'); - $this->packages = new PackageCollection(array( - new RootPackage(new RootPackageFile('vendor/root'), '/root'), - new Package(new PackageFile('vendor/package1'), '/package1'), - new Package(new PackageFile('vendor/package2'), '/package2'), + $this->modules = new ModuleList(array( + new RootModule(new RootModuleFile('vendor/root'), '/root'), + new Module(new ModuleFile('vendor/package1'), '/package1'), + new Module(new ModuleFile('vendor/package2'), '/package2'), )); - $this->handler = new BindCommandHandler($this->discoveryManager, $this->packages); + $this->handler = new BindCommandHandler($this->discoveryManager, $this->modules); } public function testListAllBindings() @@ -916,7 +916,7 @@ public function testUpdateResourceBinding() 'param2' => 'value2', ), 'glob'); $descriptor = new BindingDescriptor($binding); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $uuid = $descriptor->getUuid(); $this->discoveryManager->expects($this->at(0)) @@ -948,7 +948,7 @@ public function testUpdateResourceBindingWithRelativePath() { $args = self::$updateCommand->parseArgs(new StringArgs('ab12 --query new')); $descriptor = new BindingDescriptor(new ResourceBinding('/old', Foo::clazz)); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->at(0)) ->method('findBindingDescriptors') @@ -979,7 +979,7 @@ public function testUpdateClassBinding() 'param2' => 'value2', )); $descriptor = new BindingDescriptor($binding); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $uuid = $descriptor->getUuid(); $this->discoveryManager->expects($this->at(0)) @@ -1014,7 +1014,7 @@ public function testUpdateBindingWithUnsetParameter() 'param2' => 'value2', ), 'glob'); $descriptor = new BindingDescriptor($binding); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->at(0)) ->method('findBindingDescriptors') @@ -1041,7 +1041,7 @@ public function testUpdateBindingForce() { $args = self::$updateCommand->parseArgs(new StringArgs('ab12 --query /new --force')); $descriptor = new BindingDescriptor(new ResourceBinding('/old', Foo::clazz)); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->at(0)) ->method('findBindingDescriptors') @@ -1072,7 +1072,7 @@ public function testUpdateBindingFailsIfNoUpdateProvided() { $args = self::$updateCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/old', Foo::clazz)); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1095,7 +1095,7 @@ public function testUpdateBindingFailsIfNoRootBinding() { $args = self::$updateCommand->parseArgs(new StringArgs('ab12 --query /new')); $descriptor = new BindingDescriptor(new ResourceBinding('/old', Foo::clazz)); - $descriptor->load($this->packages->get('vendor/package1')); + $descriptor->load($this->modules->get('vendor/package1')); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1114,7 +1114,7 @@ public function testDeleteBinding() { $args = self::$deleteCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1183,7 +1183,7 @@ public function testDeleteBindingFailsIfNoRootBinding() { $args = self::$deleteCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->packages->get('vendor/package1')); + $descriptor->load($this->modules->get('vendor/package1')); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1202,7 +1202,7 @@ public function testEnableBinding() { $args = self::$enableCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->packages->get('vendor/package1')); + $descriptor->load($this->modules->get('vendor/package1')); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1243,7 +1243,7 @@ public function testEnableBindingFailsIfRoot() { $args = self::$enableCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1260,7 +1260,7 @@ public function testDisableBinding() { $args = self::$disableCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->packages->get('vendor/package1')); + $descriptor->load($this->modules->get('vendor/package1')); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1301,7 +1301,7 @@ public function testDisableBindingFailsIfRoot() { $args = self::$disableCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->packages->getRootPackage()); + $descriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1369,9 +1369,9 @@ private function initDefaultBindings() ))); } - private function packageAndState($packageName, $state) + private function packageAndState($moduleName, $state) { - return Expr::method('getContainingPackage', Expr::method('getName', Expr::same($packageName))) + return Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($state)); } diff --git a/tests/Handler/ConfigCommandHandlerTest.php b/tests/Handler/ConfigCommandHandlerTest.php index fad7e90..31521dc 100644 --- a/tests/Handler/ConfigCommandHandlerTest.php +++ b/tests/Handler/ConfigCommandHandlerTest.php @@ -13,7 +13,7 @@ use PHPUnit_Framework_MockObject_MockObject; use Puli\Cli\Handler\ConfigCommandHandler; -use Puli\Manager\Api\Package\RootPackageFileManager; +use Puli\Manager\Api\Module\RootModuleFileManager; use Webmozart\Console\Api\Command\Command; use Webmozart\Console\Args\StringArgs; @@ -45,7 +45,7 @@ class ConfigCommandHandlerTest extends AbstractCommandHandlerTest private static $resetCommand; /** - * @var PHPUnit_Framework_MockObject_MockObject|RootPackageFileManager + * @var PHPUnit_Framework_MockObject_MockObject|RootModuleFileManager */ private $manager; @@ -68,7 +68,7 @@ protected function setUp() { parent::setUp(); - $this->manager = $this->getMock('Puli\Manager\Api\Package\RootPackageFileManager'); + $this->manager = $this->getMock('Puli\Manager\Api\Module\RootModuleFileManager'); $this->handler = new ConfigCommandHandler($this->manager); } diff --git a/tests/Handler/MapCommandHandlerTest.php b/tests/Handler/MapCommandHandlerTest.php index 0f7e7d1..b2f1bfa 100644 --- a/tests/Handler/MapCommandHandlerTest.php +++ b/tests/Handler/MapCommandHandlerTest.php @@ -13,11 +13,11 @@ use PHPUnit_Framework_MockObject_MockObject; use Puli\Cli\Handler\MapCommandHandler; -use Puli\Manager\Api\Package\Package; -use Puli\Manager\Api\Package\PackageCollection; -use Puli\Manager\Api\Package\PackageFile; -use Puli\Manager\Api\Package\RootPackage; -use Puli\Manager\Api\Package\RootPackageFile; +use Puli\Manager\Api\Module\Module; +use Puli\Manager\Api\Module\ModuleList; +use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\RootModule; +use Puli\Manager\Api\Module\RootModuleFile; use Puli\Manager\Api\Repository\PathConflict; use Puli\Manager\Api\Repository\PathMapping; use Puli\Manager\Api\Repository\PathMappingState; @@ -60,7 +60,7 @@ class MapCommandHandlerTest extends AbstractCommandHandlerTest private $repoManager; /** - * @var PackageCollection + * @var ModuleList */ private $packages; @@ -84,10 +84,10 @@ protected function setUp() parent::setUp(); $this->repoManager = $this->getMock('Puli\Manager\Api\Repository\RepositoryManager'); - $this->packages = new PackageCollection(array( - new RootPackage(new RootPackageFile('vendor/root'), '/root'), - new Package(new PackageFile('vendor/package1'), '/package1'), - new Package(new PackageFile('vendor/package2'), '/package2'), + $this->packages = new ModuleList(array( + new RootModule(new RootModuleFile('vendor/root'), '/root'), + new Module(new ModuleFile('vendor/package1'), '/package1'), + new Module(new ModuleFile('vendor/package2'), '/package2'), )); $this->handler = new MapCommandHandler($this->repoManager, $this->packages); } @@ -616,7 +616,7 @@ public function testUpdateMappingAddPathReferences() $args = self::$updateCommand->parseArgs(new StringArgs('/path --add assets --add res')); $mapping = new PathMapping('/path', array('previous')); - $mapping->load($this->packages->getRootPackage(), $this->packages); + $mapping->load($this->packages->getRootModule(), $this->packages); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -635,7 +635,7 @@ public function testUpdateMappingRemovePathReference() $args = self::$updateCommand->parseArgs(new StringArgs('/path --remove assets')); $mapping = new PathMapping('/path', array('assets', 'res')); - $mapping->load($this->packages->getRootPackage(), $this->packages); + $mapping->load($this->packages->getRootModule(), $this->packages); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -654,7 +654,7 @@ public function testUpdateMappingRemoveAllPathReferences() $args = self::$updateCommand->parseArgs(new StringArgs('/path --remove assets --remove res')); $mapping = new PathMapping('/path', array('assets', 'res')); - $mapping->load($this->packages->getRootPackage(), $this->packages); + $mapping->load($this->packages->getRootModule(), $this->packages); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -673,7 +673,7 @@ public function testUpdateMappingRelativePath() $args = self::$updateCommand->parseArgs(new StringArgs('rel --add assets')); $mapping = new PathMapping('/rel', array('previous')); - $mapping->load($this->packages->getRootPackage(), $this->packages); + $mapping->load($this->packages->getRootModule(), $this->packages); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -692,7 +692,7 @@ public function testUpdateMappingForce() $args = self::$updateCommand->parseArgs(new StringArgs('/path --add assets --force')); $mapping = new PathMapping('/path', array('previous')); - $mapping->load($this->packages->getRootPackage(), $this->packages); + $mapping->load($this->packages->getRootModule(), $this->packages); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -714,7 +714,7 @@ public function testUpdateMappingFailsIfNoChange() $args = self::$updateCommand->parseArgs(new StringArgs('/path')); $mapping = new PathMapping('/path', array('previous')); - $mapping->load($this->packages->getRootPackage(), $this->packages); + $mapping->load($this->packages->getRootModule(), $this->packages); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -787,7 +787,7 @@ private function initDefaultManager() $conflictMappingPackage21 = new PathMapping('/conflict1', 'res'); $conflictMappingPackage22 = new PathMapping('/conflict2', 'res'); - $conflictMappingRoot1->load($this->packages->getRootPackage(), $this->packages); + $conflictMappingRoot1->load($this->packages->getRootModule(), $this->packages); $conflictMappingPackage11->load($this->packages->get('vendor/package1'), $this->packages); $conflictMappingPackage12->load($this->packages->get('vendor/package1'), $this->packages); $conflictMappingPackage21->load($this->packages->get('vendor/package2'), $this->packages); @@ -864,15 +864,15 @@ private function initDefaultManager() ))); } - private function packageAndState($packageName, $state) + private function packageAndState($moduleName, $state) { - return Expr::method('getContainingPackage', Expr::method('getName', Expr::same($packageName))) + return Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($state)); } - private function packagesAndState(array $packageNames, $state) + private function packagesAndState(array $moduleNames, $state) { - return Expr::method('getContainingPackage', Expr::method('getName', Expr::in($packageNames))) + return Expr::method('getContainingModule', Expr::method('getName', Expr::in($moduleNames))) ->andMethod('getState', Expr::same($state)); } diff --git a/tests/Handler/PackageCommandHandlerTest.php b/tests/Handler/PackageCommandHandlerTest.php index ddaee3f..6721da8 100644 --- a/tests/Handler/PackageCommandHandlerTest.php +++ b/tests/Handler/PackageCommandHandlerTest.php @@ -15,14 +15,14 @@ use Puli\Cli\Handler\PackageCommandHandler; use Puli\Manager\Api\Context\ProjectContext; use Puli\Manager\Api\Environment; -use Puli\Manager\Api\Package\InstallInfo; -use Puli\Manager\Api\Package\Package; -use Puli\Manager\Api\Package\PackageCollection; -use Puli\Manager\Api\Package\PackageFile; -use Puli\Manager\Api\Package\PackageManager; -use Puli\Manager\Api\Package\PackageState; -use Puli\Manager\Api\Package\RootPackage; -use Puli\Manager\Api\Package\RootPackageFile; +use Puli\Manager\Api\Module\InstallInfo; +use Puli\Manager\Api\Module\Module; +use Puli\Manager\Api\Module\ModuleList; +use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\ModuleManager; +use Puli\Manager\Api\Module\ModuleState; +use Puli\Manager\Api\Module\RootModule; +use Puli\Manager\Api\Module\RootModuleFile; use RuntimeException; use Webmozart\Console\Api\Command\Command; use Webmozart\Console\Args\StringArgs; @@ -68,7 +68,7 @@ class PackageCommandHandlerTest extends AbstractCommandHandlerTest private $context; /** - * @var PHPUnit_Framework_MockObject_MockObject|PackageManager + * @var PHPUnit_Framework_MockObject_MockObject|ModuleManager */ private $packageManager; @@ -105,7 +105,7 @@ protected function setUp() $this->context = $this->getMockBuilder('Puli\Manager\Api\Context\ProjectContext') ->disableOriginalConstructor() ->getMock(); - $this->packageManager = $this->getMock('Puli\Manager\Api\Package\PackageManager'); + $this->packageManager = $this->getMock('Puli\Manager\Api\Module\ModuleManager'); $this->handler = new PackageCommandHandler($this->packageManager); $this->context->expects($this->any()) @@ -129,28 +129,28 @@ protected function setUp() $installInfo5->setInstallerName('spock'); $installInfo5->setEnvironment(Environment::DEV); - $rootPackage = new RootPackage(new RootPackageFile('vendor/root'), __DIR__.'/Fixtures/root'); - $package1 = new Package(new PackageFile('vendor/package1'), __DIR__.'/Fixtures/root/packages/package1', $installInfo1); - $package2 = new Package(new PackageFile('vendor/package2'), __DIR__.'/Fixtures/root/packages/package2', $installInfo2); - $package3 = new Package(new PackageFile('vendor/package3'), __DIR__.'/Fixtures/root/packages/package3', $installInfo3); - $package4 = new Package(null, __DIR__.'/Fixtures/root/packages/package4', $installInfo4, array(new RuntimeException('Load error'))); - $package5 = new Package(new PackageFile('vendor/package5'), __DIR__.'/Fixtures/root/packages/package5', $installInfo5); + $rootModule = new RootModule(new RootModuleFile('vendor/root'), __DIR__.'/Fixtures/root'); + $package1 = new Module(new ModuleFile('vendor/package1'), __DIR__.'/Fixtures/root/packages/package1', $installInfo1); + $package2 = new Module(new ModuleFile('vendor/package2'), __DIR__.'/Fixtures/root/packages/package2', $installInfo2); + $package3 = new Module(new ModuleFile('vendor/package3'), __DIR__.'/Fixtures/root/packages/package3', $installInfo3); + $package4 = new Module(null, __DIR__.'/Fixtures/root/packages/package4', $installInfo4, array(new RuntimeException('Load error'))); + $package5 = new Module(new ModuleFile('vendor/package5'), __DIR__.'/Fixtures/root/packages/package5', $installInfo5); $this->packageManager->expects($this->any()) - ->method('findPackages') + ->method('findModules') ->willReturnCallback($this->returnFromMap(array( - array($this->all(), new PackageCollection(array($rootPackage, $package1, $package2, $package3, $package4, $package5))), - array($this->env(array(Environment::PROD, Environment::DEV)), new PackageCollection(array($rootPackage, $package1, $package2, $package3, $package4, $package5))), - array($this->env(array(Environment::PROD)), new PackageCollection(array($rootPackage, $package1, $package2, $package3, $package4))), - array($this->env(array(Environment::DEV)), new PackageCollection(array($package5))), - array($this->installer('spock'), new PackageCollection(array($package1, $package2, $package4, $package5))), - array($this->state(PackageState::ENABLED), new PackageCollection(array($rootPackage, $package1, $package2, $package5))), - array($this->state(PackageState::NOT_FOUND), new PackageCollection(array($package3))), - array($this->state(PackageState::NOT_LOADABLE), new PackageCollection(array($package4))), - array($this->states(array(PackageState::ENABLED, PackageState::NOT_FOUND)), new PackageCollection(array($rootPackage, $package1, $package2, $package3, $package5))), - array($this->installerAndState('spock', PackageState::ENABLED), new PackageCollection(array($package1, $package2, $package5))), - array($this->installerAndState('spock', PackageState::NOT_FOUND), new PackageCollection(array())), - array($this->installerAndState('spock', PackageState::NOT_LOADABLE), new PackageCollection(array($package4))), + array($this->all(), new ModuleList(array($rootModule, $package1, $package2, $package3, $package4, $package5))), + array($this->env(array(Environment::PROD, Environment::DEV)), new ModuleList(array($rootModule, $package1, $package2, $package3, $package4, $package5))), + array($this->env(array(Environment::PROD)), new ModuleList(array($rootModule, $package1, $package2, $package3, $package4))), + array($this->env(array(Environment::DEV)), new ModuleList(array($package5))), + array($this->installer('spock'), new ModuleList(array($package1, $package2, $package4, $package5))), + array($this->state(ModuleState::ENABLED), new ModuleList(array($rootModule, $package1, $package2, $package5))), + array($this->state(ModuleState::NOT_FOUND), new ModuleList(array($package3))), + array($this->state(ModuleState::NOT_LOADABLE), new ModuleList(array($package4))), + array($this->states(array(ModuleState::ENABLED, ModuleState::NOT_FOUND)), new ModuleList(array($rootModule, $package1, $package2, $package3, $package5))), + array($this->installerAndState('spock', ModuleState::ENABLED), new ModuleList(array($package1, $package2, $package5))), + array($this->installerAndState('spock', ModuleState::NOT_FOUND), new ModuleList(array())), + array($this->installerAndState('spock', ModuleState::NOT_LOADABLE), new ModuleList(array($package4))), ))); $this->previousWd = getcwd(); @@ -439,83 +439,83 @@ public function testListPackagesWithFormat() $this->assertEmpty($this->io->fetchErrors()); } - public function testInstallPackageWithRelativePath() + public function testInstallModuleWithRelativePath() { $args = self::$installCommand->parseArgs(new StringArgs('packages/package1')); $this->packageManager->expects($this->once()) - ->method('installPackage') + ->method('installModule') ->with($this->wd.'/packages/package1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); $this->assertSame(0, $this->handler->handleInstall($args)); } - public function testInstallPackageWithAbsolutePath() + public function testInstallModuleWithAbsolutePath() { $args = self::$installCommand->parseArgs(new StringArgs('/packages/package1')); $this->packageManager->expects($this->once()) - ->method('installPackage') + ->method('installModule') ->with('/packages/package1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); $this->assertSame(0, $this->handler->handleInstall($args)); } - public function testInstallPackageWithCustomName() + public function testInstallModuleWithCustomName() { $args = self::$installCommand->parseArgs(new StringArgs('/packages/package1 custom/package1')); $this->packageManager->expects($this->once()) - ->method('installPackage') + ->method('installModule') ->with('/packages/package1', 'custom/package1', InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); $this->assertSame(0, $this->handler->handleInstall($args)); } - public function testInstallPackageWithCustomInstaller() + public function testInstallModuleWithCustomInstaller() { $args = self::$installCommand->parseArgs(new StringArgs('--installer kirk /packages/package1')); $this->packageManager->expects($this->once()) - ->method('installPackage') + ->method('installModule') ->with('/packages/package1', null, 'kirk', Environment::PROD); $this->assertSame(0, $this->handler->handleInstall($args)); } - public function testInstallDevPackage() + public function testInstallDevModule() { $args = self::$installCommand->parseArgs(new StringArgs('--dev packages/package1')); $this->packageManager->expects($this->once()) - ->method('installPackage') + ->method('installModule') ->with($this->wd.'/packages/package1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::DEV); $this->assertSame(0, $this->handler->handleInstall($args)); } - public function testRenamePackage() + public function testRenameModule() { $args = self::$renameCommand->parseArgs(new StringArgs('vendor/package1 vendor/new')); $this->packageManager->expects($this->once()) - ->method('renamePackage') + ->method('renameModule') ->with('vendor/package1', 'vendor/new'); $this->assertSame(0, $this->handler->handleRename($args)); } - public function testDeletePackage() + public function testDeleteModule() { $args = self::$deleteCommand->parseArgs(new StringArgs('vendor/package1')); $this->packageManager->expects($this->once()) - ->method('hasPackage') + ->method('hasModule') ->with('vendor/package1') ->willReturn(true); $this->packageManager->expects($this->once()) - ->method('removePackage') + ->method('removeModule') ->with('vendor/package1'); $this->assertSame(0, $this->handler->handleDelete($args)); @@ -525,29 +525,29 @@ public function testDeletePackage() * @expectedException \RuntimeException * @expectedExceptionMessage The package "vendor/package1" is not installed. */ - public function testDeletePackageFailsIfNotFound() + public function testDeleteModuleFailsIfNotFound() { $args = self::$deleteCommand->parseArgs(new StringArgs('vendor/package1')); $this->packageManager->expects($this->once()) - ->method('hasPackage') + ->method('hasModule') ->with('vendor/package1') ->willReturn(false); $this->packageManager->expects($this->never()) - ->method('removePackage') + ->method('removeModule') ->with('vendor/package1'); $this->handler->handleDelete($args); } - public function testCleanPackages() + public function testCleanModules() { $args = self::$cleanCommand->parseArgs(new StringArgs('')); // The not-found package $this->packageManager->expects($this->once()) - ->method('removePackage') + ->method('removeModule') ->with('vendor/package3'); $expected = <<<'EOF' diff --git a/tests/Handler/PluginCommandHandlerTest.php b/tests/Handler/PluginCommandHandlerTest.php index 1f9aafe..65f71c9 100644 --- a/tests/Handler/PluginCommandHandlerTest.php +++ b/tests/Handler/PluginCommandHandlerTest.php @@ -13,7 +13,7 @@ use PHPUnit_Framework_MockObject_MockObject; use Puli\Cli\Handler\PluginCommandHandler; -use Puli\Manager\Api\Package\RootPackageFileManager; +use Puli\Manager\Api\Module\RootModuleFileManager; use Webmozart\Console\Api\Command\Command; use Webmozart\Console\Args\StringArgs; @@ -40,7 +40,7 @@ class PluginCommandHandlerTest extends AbstractCommandHandlerTest private static $deleteCommand; /** - * @var PHPUnit_Framework_MockObject_MockObject|RootPackageFileManager + * @var PHPUnit_Framework_MockObject_MockObject|RootModuleFileManager */ private $manager; @@ -62,7 +62,7 @@ protected function setUp() { parent::setUp(); - $this->manager = $this->getMock('Puli\Manager\Api\Package\RootPackageFileManager'); + $this->manager = $this->getMock('Puli\Manager\Api\Module\RootModuleFileManager'); $this->handler = new PluginCommandHandler($this->manager); } diff --git a/tests/Handler/TypeCommandHandlerTest.php b/tests/Handler/TypeCommandHandlerTest.php index 886212a..95854d1 100644 --- a/tests/Handler/TypeCommandHandlerTest.php +++ b/tests/Handler/TypeCommandHandlerTest.php @@ -18,11 +18,11 @@ use Puli\Manager\Api\Discovery\BindingTypeDescriptor; use Puli\Manager\Api\Discovery\BindingTypeState; use Puli\Manager\Api\Discovery\DiscoveryManager; -use Puli\Manager\Api\Package\Package; -use Puli\Manager\Api\Package\PackageCollection; -use Puli\Manager\Api\Package\PackageFile; -use Puli\Manager\Api\Package\RootPackage; -use Puli\Manager\Api\Package\RootPackageFile; +use Puli\Manager\Api\Module\Module; +use Puli\Manager\Api\Module\ModuleList; +use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\RootModule; +use Puli\Manager\Api\Module\RootModuleFile; use Webmozart\Console\Api\Command\Command; use Webmozart\Console\Args\StringArgs; use Webmozart\Expression\Expr; @@ -61,7 +61,7 @@ class TypeCommandHandlerTest extends AbstractCommandHandlerTest private $discoveryManager; /** - * @var PackageCollection + * @var ModuleList */ private $packages; @@ -85,10 +85,10 @@ protected function setUp() parent::setUp(); $this->discoveryManager = $this->getMock('Puli\Manager\Api\Discovery\DiscoveryManager'); - $this->packages = new PackageCollection(array( - new RootPackage(new RootPackageFile('vendor/root'), '/root'), - new Package(new PackageFile('vendor/package1'), '/package1'), - new Package(new PackageFile('vendor/package2'), '/package2'), + $this->packages = new ModuleList(array( + new RootModule(new RootModuleFile('vendor/root'), '/root'), + new Module(new ModuleFile('vendor/package1'), '/package1'), + new Module(new ModuleFile('vendor/package2'), '/package2'), )); $this->handler = new TypeCommandHandler($this->discoveryManager, $this->packages); @@ -553,7 +553,7 @@ public function testUpdateTypeDescription() $args = self::$updateCommand->parseArgs(new StringArgs('my/type --description "New description"')); $typeDescriptor = new BindingTypeDescriptor(new BindingType('my/type'), 'Old description'); - $typeDescriptor->load($this->packages->getRootPackage()); + $typeDescriptor->load($this->packages->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -578,7 +578,7 @@ public function testUpdateTypeOptionalParameterToRequired() null, array('param' => 'The description') ); - $typeDescriptor->load($this->packages->getRootPackage()); + $typeDescriptor->load($this->packages->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -609,7 +609,7 @@ public function testUpdateTypeRequiredParameterToOptional() null, array('param' => 'The description') ); - $typeDescriptor->load($this->packages->getRootPackage()); + $typeDescriptor->load($this->packages->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -640,7 +640,7 @@ public function testUpdateTypeChangeParameterDescription() null, array('param' => 'Old description') ); - $typeDescriptor->load($this->packages->getRootPackage()); + $typeDescriptor->load($this->packages->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -670,7 +670,7 @@ public function testUpdateTypeRemoveParameter() new BindingParameter('param2', BindingParameter::OPTIONAL), )) ); - $typeDescriptor->load($this->packages->getRootPackage()); + $typeDescriptor->load($this->packages->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -696,7 +696,7 @@ public function testUpdateTypeFailsIfNoChanges() $args = self::$updateCommand->parseArgs(new StringArgs('my/type')); $typeDescriptor = new BindingTypeDescriptor(new BindingType('my/type')); - $typeDescriptor->load($this->packages->getRootPackage()); + $typeDescriptor->load($this->packages->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -744,9 +744,9 @@ public function testDeleteTypeFailsIfNotFound() $this->assertSame(0, $this->handler->handleDelete($args)); } - private function packageAndState($packageName, $state) + private function packageAndState($moduleName, $state) { - return Expr::method('getContainingPackage', Expr::method('getName', Expr::same($packageName))) + return Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($state)); } diff --git a/tests/Handler/UpgradeCommandHandlerTest.php b/tests/Handler/UpgradeCommandHandlerTest.php index f30f2a6..a666c83 100644 --- a/tests/Handler/UpgradeCommandHandlerTest.php +++ b/tests/Handler/UpgradeCommandHandlerTest.php @@ -13,9 +13,9 @@ use PHPUnit_Framework_MockObject_MockObject; use Puli\Cli\Handler\UpgradeCommandHandler; -use Puli\Manager\Api\Package\PackageFile; -use Puli\Manager\Api\Package\RootPackageFile; -use Puli\Manager\Api\Package\RootPackageFileManager; +use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\RootModuleFile; +use Puli\Manager\Api\Module\RootModuleFileManager; use Webmozart\Console\Api\Command\Command; use Webmozart\Console\Args\StringArgs; @@ -32,12 +32,12 @@ class UpgradeCommandHandlerTest extends AbstractCommandHandlerTest private static $upgradeCommand; /** - * @var PHPUnit_Framework_MockObject_MockObject|RootPackageFileManager + * @var PHPUnit_Framework_MockObject_MockObject|RootModuleFileManager */ private $packageFileManager; /** - * @var RootPackageFile + * @var RootModuleFile */ private $packageFile; @@ -57,10 +57,10 @@ protected function setUp() { parent::setUp(); - $this->packageFileManager = $this->getMock('Puli\Manager\Api\Package\RootPackageFileManager'); - $this->packageFile = new RootPackageFile(); + $this->packageFileManager = $this->getMock('Puli\Manager\Api\Module\RootModuleFileManager'); + $this->packageFile = new RootModuleFile(); $this->packageFileManager->expects($this->any()) - ->method('getPackageFile') + ->method('getModuleFile') ->willReturn($this->packageFile); $this->handler = new UpgradeCommandHandler($this->packageFileManager); } @@ -68,7 +68,7 @@ protected function setUp() public function testUpgradeToDefaultVersion() { $args = self::$upgradeCommand->parseArgs(new StringArgs('')); - $defaultVersion = PackageFile::DEFAULT_VERSION; + $defaultVersion = ModuleFile::DEFAULT_VERSION; $this->packageFile->setVersion('0.5'); From f70d9c965b5c83871ae6b6ee31c9f2d2e0557d1e Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 29 Jul 2016 10:54:20 +0200 Subject: [PATCH 2/7] Style fix --- src/Handler/BindCommandHandler.php | 46 +++++++-------- src/Handler/ConfigCommandHandler.php | 22 +++---- src/Handler/MapCommandHandler.php | 44 +++++++------- src/Handler/PackageCommandHandler.php | 64 ++++++++++----------- src/Handler/PluginCommandHandler.php | 16 +++--- src/Handler/TypeCommandHandler.php | 36 ++++++------ src/Handler/UpgradeCommandHandler.php | 8 +-- src/Proxy/DiscoveryManagerProxy.php | 4 +- src/Proxy/RepositoryManagerProxy.php | 2 +- src/PuliApplicationConfig.php | 4 +- src/Util/ArgsUtil.php | 12 ++-- tests/Handler/BindCommandHandlerTest.php | 2 +- tests/Handler/MapCommandHandlerTest.php | 2 +- tests/Handler/PackageCommandHandlerTest.php | 2 +- tests/Handler/TypeCommandHandlerTest.php | 2 +- 15 files changed, 133 insertions(+), 133 deletions(-) diff --git a/src/Handler/BindCommandHandler.php b/src/Handler/BindCommandHandler.php index 6a5220d..6bae72f 100644 --- a/src/Handler/BindCommandHandler.php +++ b/src/Handler/BindCommandHandler.php @@ -55,8 +55,8 @@ class BindCommandHandler /** * Creates the handler. * - * @param DiscoveryManager $discoveryManager The discovery manager. - * @param ModuleList $modules The loaded packages. + * @param DiscoveryManager $discoveryManager The discovery manager + * @param ModuleList $modules The loaded packages */ public function __construct(DiscoveryManager $discoveryManager, ModuleList $modules) { @@ -67,10 +67,10 @@ public function __construct(DiscoveryManager $discoveryManager, ModuleList $modu /** * Handles the "bind --list" command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handleList(Args $args, IO $io) { @@ -128,9 +128,9 @@ public function handleList(Args $args, IO $io) /** * Handles the "bind " command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleAdd(Args $args) { @@ -167,9 +167,9 @@ public function handleAdd(Args $args) /** * Handles the "bind --update " command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleUpdate(Args $args) { @@ -213,9 +213,9 @@ public function handleUpdate(Args $args) /** * Handles the "bind --delete" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleDelete(Args $args) { @@ -236,9 +236,9 @@ public function handleDelete(Args $args) /** * Handles the "bind --enable" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleEnable(Args $args) { @@ -259,9 +259,9 @@ public function handleEnable(Args $args) /** * Handles the "bind --disable" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleDisable(Args $args) { @@ -282,9 +282,9 @@ public function handleDisable(Args $args) /** * Returns the binding states selected in the console arguments. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int[] The selected {@link BindingState} constants. + * @return int[] The selected {@link BindingState} constants */ private function getBindingStates(Args $args) { @@ -306,12 +306,12 @@ private function getBindingStates(Args $args) /** * Prints a list of binding descriptors. * - * @param IO $io The I/O. - * @param BindingDescriptor[] $descriptors The binding descriptors. - * @param int $indentation The number of spaces to indent. + * @param IO $io The I/O + * @param BindingDescriptor[] $descriptors The binding descriptors + * @param int $indentation The number of spaces to indent * @param bool $enabled Whether the binding descriptors * are enabled. If not, the output - * is printed in red. + * is printed in red */ private function printBindingTable(IO $io, array $descriptors, $indentation = 0, $enabled = true) { @@ -372,8 +372,8 @@ private function printBindingTable(IO $io, array $descriptors, $indentation = 0, /** * Prints the header for a binding state. * - * @param IO $io The I/O. - * @param int $bindingState The {@link BindingState} constant. + * @param IO $io The I/O + * @param int $bindingState The {@link BindingState} constant */ private function printBindingStateHeader(IO $io, $bindingState) { diff --git a/src/Handler/ConfigCommandHandler.php b/src/Handler/ConfigCommandHandler.php index 0e348ef..81d22fc 100644 --- a/src/Handler/ConfigCommandHandler.php +++ b/src/Handler/ConfigCommandHandler.php @@ -35,7 +35,7 @@ class ConfigCommandHandler /** * Creates the handler. * - * @param RootModuleFileManager $manager The root package file manager. + * @param RootModuleFileManager $manager The root package file manager */ public function __construct(RootModuleFileManager $manager) { @@ -45,10 +45,10 @@ public function __construct(RootModuleFileManager $manager) /** * Handles the "config" command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handleList(Args $args, IO $io) { @@ -77,10 +77,10 @@ public function handleList(Args $args, IO $io) /** * Handles the "config " command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handleShow(Args $args, IO $io) { @@ -95,9 +95,9 @@ public function handleShow(Args $args, IO $io) /** * Handles the "config " command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleSet(Args $args) { @@ -111,9 +111,9 @@ public function handleSet(Args $args) /** * Handles the "config -r " command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleReset(Args $args) { diff --git a/src/Handler/MapCommandHandler.php b/src/Handler/MapCommandHandler.php index ba87c1d..3aadb7d 100644 --- a/src/Handler/MapCommandHandler.php +++ b/src/Handler/MapCommandHandler.php @@ -52,8 +52,8 @@ class MapCommandHandler /** * Creates the handler. * - * @param RepositoryManager $repoManager The repository manager. - * @param ModuleList $modules The loaded packages. + * @param RepositoryManager $repoManager The repository manager + * @param ModuleList $modules The loaded packages */ public function __construct(RepositoryManager $repoManager, ModuleList $modules) { @@ -64,10 +64,10 @@ public function __construct(RepositoryManager $repoManager, ModuleList $modules) /** * Handles the "puli map --list" command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handleList(Args $args, IO $io) { @@ -150,9 +150,9 @@ public function handleList(Args $args, IO $io) /** * Handles the "puli map" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleAdd(Args $args) { @@ -170,9 +170,9 @@ public function handleAdd(Args $args) /** * Handles the "puli map --update" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleUpdate(Args $args) { @@ -211,9 +211,9 @@ public function handleUpdate(Args $args) /** * Handles the "puli map --delete" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleDelete(Args $args) { @@ -235,12 +235,12 @@ public function handleDelete(Args $args) /** * Prints a list of path mappings. * - * @param IO $io The I/O. - * @param PathMapping[] $mappings The path mappings. + * @param IO $io The I/O + * @param PathMapping[] $mappings The path mappings * @param int $indentation The number of spaces to indent the - * output. + * output * @param bool $enabled Whether the path mappings are enabled. - * If not, the output is printed in red. + * If not, the output is printed in red */ private function printMappingTable(IO $io, array $mappings, $indentation = 0, $enabled = true) { @@ -281,10 +281,10 @@ private function printMappingTable(IO $io, array $mappings, $indentation = 0, $e /** * Prints a list of conflicting path mappings. * - * @param IO $io The I/O. - * @param PathMapping[] $mappings The path mappings. + * @param IO $io The I/O + * @param PathMapping[] $mappings The path mappings * @param int $indentation The number of spaces to indent the - * output. + * output */ private function printConflictTable(IO $io, array $mappings, $indentation = 0) { @@ -332,9 +332,9 @@ private function printConflictTable(IO $io, array $mappings, $indentation = 0) /** * Returns the path mapping states selected in the console arguments. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int[] The selected {@link PathMappingState} constants. + * @return int[] The selected {@link PathMappingState} constants */ private function getPathMappingStates(Args $args) { @@ -354,8 +354,8 @@ private function getPathMappingStates(Args $args) /** * Prints the header for a path mapping state. * - * @param IO $io The I/O. - * @param int $pathMappingState The {@link PathMappingState} constant. + * @param IO $io The I/O + * @param int $pathMappingState The {@link PathMappingState} constant */ private function printPathMappingStateHeader(IO $io, $pathMappingState) { diff --git a/src/Handler/PackageCommandHandler.php b/src/Handler/PackageCommandHandler.php index 43f8987..9f2db5c 100644 --- a/src/Handler/PackageCommandHandler.php +++ b/src/Handler/PackageCommandHandler.php @@ -51,7 +51,7 @@ class PackageCommandHandler /** * Creates the handler. * - * @param ModuleManager $moduleManager The package manager. + * @param ModuleManager $moduleManager The package manager */ public function __construct(ModuleManager $moduleManager) { @@ -61,10 +61,10 @@ public function __construct(ModuleManager $moduleManager) /** * Handles the "package --list" command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handleList(Args $args, IO $io) { @@ -82,9 +82,9 @@ public function handleList(Args $args, IO $io) /** * Handles the "package --install" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleInstall(Args $args) { @@ -101,9 +101,9 @@ public function handleInstall(Args $args) /** * Handles the "package --rename" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleRename(Args $args) { @@ -118,9 +118,9 @@ public function handleRename(Args $args) /** * Handles the "package --delete" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleDelete(Args $args) { @@ -141,10 +141,10 @@ public function handleDelete(Args $args) /** * Handles the "package --clean" command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handleClean(Args $args, IO $io) { @@ -162,9 +162,9 @@ public function handleClean(Args $args, IO $io) * Returns the package states that should be displayed for the given * console arguments. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int[] A list of {@link ModuleState} constants. + * @return int[] A list of {@link ModuleState} constants */ private function getSelectedStates(Args $args) { @@ -189,9 +189,9 @@ private function getSelectedStates(Args $args) * Returns the packages that should be displayed for the given console * arguments. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return ModuleList The packages. + * @return ModuleList The packages */ private function getSelectedPackages(Args $args) { @@ -225,9 +225,9 @@ private function getSelectedPackages(Args $args) /** * Prints packages with intermediate headers for the package states. * - * @param IO $io The I/O. - * @param ModuleList $modules The packages to print. - * @param int[] $states The states to print. + * @param IO $io The I/O + * @param ModuleList $modules The packages to print + * @param int[] $states The states to print */ private function printPackagesByState(IO $io, ModuleList $modules, array $states) { @@ -262,9 +262,9 @@ private function printPackagesByState(IO $io, ModuleList $modules, array $states /** * Prints packages using the given format. * - * @param IO $io The I/O. - * @param ModuleList $modules The packages to print. - * @param string $format The format string. + * @param IO $io The I/O + * @param ModuleList $modules The packages to print + * @param string $format The format string */ private function printPackagesWithFormat(IO $io, ModuleList $modules, $format) { @@ -285,8 +285,8 @@ private function printPackagesWithFormat(IO $io, ModuleList $modules, $format) /** * Prints the heading for a given package state. * - * @param IO $io The I/O. - * @param int $ModuleState The {@link ModuleState} constant. + * @param IO $io The I/O + * @param int $ModuleState The {@link ModuleState} constant */ private function printModuleState(IO $io, $ModuleState) { @@ -313,11 +313,11 @@ private function printModuleState(IO $io, $ModuleState) /** * Prints a list of packages in a table. * - * @param IO $io The I/O. - * @param Module[] $modules The packages. + * @param IO $io The I/O + * @param Module[] $modules The packages * @param string|null $styleTag The tag used to style the output. If `null`, - * the default colors are used. - * @param bool $indent Whether to indent the output. + * the default colors are used + * @param bool $indent Whether to indent the output */ private function printPackageTable(IO $io, array $modules, $styleTag = null, $indent = false) { @@ -351,9 +351,9 @@ private function printPackageTable(IO $io, array $modules, $styleTag = null, $in /** * Prints not-loadable packages in a table. * - * @param IO $io The I/O. - * @param Module[] $modules The not-loadable packages. - * @param bool $indent Whether to indent the output. + * @param IO $io The I/O + * @param Module[] $modules The not-loadable packages + * @param bool $indent Whether to indent the output */ private function printNotLoadablePackages(IO $io, array $modules, $indent = false) { diff --git a/src/Handler/PluginCommandHandler.php b/src/Handler/PluginCommandHandler.php index c915d91..e9ceed3 100644 --- a/src/Handler/PluginCommandHandler.php +++ b/src/Handler/PluginCommandHandler.php @@ -33,7 +33,7 @@ class PluginCommandHandler /** * Creates the handler. * - * @param RootModuleFileManager $manager The root package file manager. + * @param RootModuleFileManager $manager The root package file manager */ public function __construct(RootModuleFileManager $manager) { @@ -43,10 +43,10 @@ public function __construct(RootModuleFileManager $manager) /** * Handles the "puli plugin --list" command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handleList(Args $args, IO $io) { @@ -68,9 +68,9 @@ public function handleList(Args $args, IO $io) /** * Handles the "puli plugin --install" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleInstall(Args $args) { @@ -91,9 +91,9 @@ public function handleInstall(Args $args) /** * Handles the "puli plugin --remove" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleDelete(Args $args) { diff --git a/src/Handler/TypeCommandHandler.php b/src/Handler/TypeCommandHandler.php index b85ba28..1ab7663 100644 --- a/src/Handler/TypeCommandHandler.php +++ b/src/Handler/TypeCommandHandler.php @@ -48,8 +48,8 @@ class TypeCommandHandler /** * Creates the handler. * - * @param DiscoveryManager $discoveryManager The discovery manager. - * @param ModuleList $modules The loaded packages. + * @param DiscoveryManager $discoveryManager The discovery manager + * @param ModuleList $modules The loaded packages */ public function __construct(DiscoveryManager $discoveryManager, ModuleList $modules) { @@ -60,10 +60,10 @@ public function __construct(DiscoveryManager $discoveryManager, ModuleList $modu /** * Handles the "puli type --list" command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handleList(Args $args, IO $io) { @@ -130,9 +130,9 @@ public function handleList(Args $args, IO $io) /** * Handles the "puli type --define" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleDefine(Args $args) { @@ -155,9 +155,9 @@ public function handleDefine(Args $args) /** * Handles the "puli type --update" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleUpdate(Args $args) { @@ -193,9 +193,9 @@ public function handleUpdate(Args $args) /** * Handles the "puli type --delete" command. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int The status code. + * @return int The status code */ public function handleDelete(Args $args) { @@ -217,9 +217,9 @@ public function handleDelete(Args $args) /** * Returns the binding type states selected in the console arguments. * - * @param Args $args The console arguments. + * @param Args $args The console arguments * - * @return int[] A list of {@link BindingTypeState} constants. + * @return int[] A list of {@link BindingTypeState} constants */ private function getBindingTypeStates(Args $args) { @@ -239,10 +239,10 @@ private function getBindingTypeStates(Args $args) /** * Prints the binding types in a table. * - * @param IO $io The I/O. - * @param BindingTypeDescriptor[] $descriptors The type descriptors to print. + * @param IO $io The I/O + * @param BindingTypeDescriptor[] $descriptors The type descriptors to print * @param string $styleTag The tag used to style the output - * @param int $indentation The number of spaces to indent. + * @param int $indentation The number of spaces to indent */ private function printTypeTable(IO $io, array $descriptors, $styleTag = null, $indentation = 0) { @@ -286,8 +286,8 @@ private function printTypeTable(IO $io, array $descriptors, $styleTag = null, $i /** * Prints the heading for a binding type state. * - * @param IO $io The I/O. - * @param int $typeState The {@link BindingTypeState} constant. + * @param IO $io The I/O + * @param int $typeState The {@link BindingTypeState} constant */ private function printBindingTypeState(IO $io, $typeState) { diff --git a/src/Handler/UpgradeCommandHandler.php b/src/Handler/UpgradeCommandHandler.php index 287ad09..fef45a3 100644 --- a/src/Handler/UpgradeCommandHandler.php +++ b/src/Handler/UpgradeCommandHandler.php @@ -33,7 +33,7 @@ class UpgradeCommandHandler * Creates the command handler. * * @param RootModuleFileManager $packageFileManager The manager of the - * puli.json file. + * puli.json file */ public function __construct(RootModuleFileManager $packageFileManager) { @@ -43,10 +43,10 @@ public function __construct(RootModuleFileManager $packageFileManager) /** * Handles the "upgrade" command. * - * @param Args $args The console arguments. - * @param IO $io The I/O. + * @param Args $args The console arguments + * @param IO $io The I/O * - * @return int The status code. + * @return int The status code */ public function handle(Args $args, IO $io) { diff --git a/src/Proxy/DiscoveryManagerProxy.php b/src/Proxy/DiscoveryManagerProxy.php index be13409..aa8f1c9 100644 --- a/src/Proxy/DiscoveryManagerProxy.php +++ b/src/Proxy/DiscoveryManagerProxy.php @@ -11,10 +11,10 @@ namespace Puli\Cli\Proxy; +use Puli\Manager\Api\Container; use Puli\Manager\Api\Discovery\BindingDescriptor; use Puli\Manager\Api\Discovery\BindingTypeDescriptor; use Puli\Manager\Api\Discovery\DiscoveryManager; -use Puli\Manager\Api\Container; use Rhumsaa\Uuid\Uuid; use Webmozart\Expression\Expression; @@ -36,7 +36,7 @@ class DiscoveryManagerProxy implements DiscoveryManager * Creates the proxy. * * @param Container $puli The service locator to fetch the actual discovery - * manager from. + * manager from */ public function __construct(Container $puli) { diff --git a/src/Proxy/RepositoryManagerProxy.php b/src/Proxy/RepositoryManagerProxy.php index 3ad781f..4cecca8 100644 --- a/src/Proxy/RepositoryManagerProxy.php +++ b/src/Proxy/RepositoryManagerProxy.php @@ -34,7 +34,7 @@ class RepositoryManagerProxy implements RepositoryManager * Creates the proxy. * * @param Container $puli The service locator to fetch the actual repository - * manager from. + * manager from */ public function __construct(Container $puli) { diff --git a/src/PuliApplicationConfig.php b/src/PuliApplicationConfig.php index 20f6af8..dfe796d 100644 --- a/src/PuliApplicationConfig.php +++ b/src/PuliApplicationConfig.php @@ -30,10 +30,10 @@ use Puli\Cli\Handler\UrlCommandHandler; use Puli\Cli\Proxy\DiscoveryManagerProxy; use Puli\Cli\Proxy\RepositoryManagerProxy; +use Puli\Manager\Api\Container; use Puli\Manager\Api\Context\ProjectContext; use Puli\Manager\Api\Module\InstallInfo; use Puli\Manager\Api\Module\ModuleFile; -use Puli\Manager\Api\Container; use Puli\Manager\Api\Server\Server; use Webmozart\Console\Api\Args\Format\Argument; use Webmozart\Console\Api\Args\Format\Option; @@ -65,7 +65,7 @@ class PuliApplicationConfig extends DefaultApplicationConfig /** * Creates the configuration. * - * @param Container $puli The Puli service container. + * @param Container $puli The Puli service container */ public function __construct(Container $puli = null) { diff --git a/src/Util/ArgsUtil.php b/src/Util/ArgsUtil.php index 523a1ed..e7917f1 100644 --- a/src/Util/ArgsUtil.php +++ b/src/Util/ArgsUtil.php @@ -26,10 +26,10 @@ class ArgsUtil /** * Returns the packages selected in the console arguments. * - * @param Args $args The console arguments. - * @param ModuleList $packages The available packages. + * @param Args $args The console arguments + * @param ModuleList $packages The available packages * - * @return string[] The package names. + * @return string[] The package names */ public static function getPackageNames(Args $args, ModuleList $packages) { @@ -54,10 +54,10 @@ public static function getPackageNames(Args $args, ModuleList $packages) /** * Returns the non-root packages selected in the console arguments. * - * @param Args $args The console arguments. - * @param ModuleList $packages The available packages. + * @param Args $args The console arguments + * @param ModuleList $packages The available packages * - * @return string[] The package names. + * @return string[] The package names */ public static function getPackageNamesWithoutRoot(Args $args, ModuleList $packages) { diff --git a/tests/Handler/BindCommandHandlerTest.php b/tests/Handler/BindCommandHandlerTest.php index c99c822..b6014eb 100644 --- a/tests/Handler/BindCommandHandlerTest.php +++ b/tests/Handler/BindCommandHandlerTest.php @@ -22,8 +22,8 @@ use Puli\Manager\Api\Discovery\BindingState; use Puli\Manager\Api\Discovery\DiscoveryManager; use Puli\Manager\Api\Module\Module; -use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Module\RootModule; use Puli\Manager\Api\Module\RootModuleFile; use Rhumsaa\Uuid\Uuid; diff --git a/tests/Handler/MapCommandHandlerTest.php b/tests/Handler/MapCommandHandlerTest.php index b2f1bfa..70a87c1 100644 --- a/tests/Handler/MapCommandHandlerTest.php +++ b/tests/Handler/MapCommandHandlerTest.php @@ -14,8 +14,8 @@ use PHPUnit_Framework_MockObject_MockObject; use Puli\Cli\Handler\MapCommandHandler; use Puli\Manager\Api\Module\Module; -use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Module\RootModule; use Puli\Manager\Api\Module\RootModuleFile; use Puli\Manager\Api\Repository\PathConflict; diff --git a/tests/Handler/PackageCommandHandlerTest.php b/tests/Handler/PackageCommandHandlerTest.php index 6721da8..90a5d51 100644 --- a/tests/Handler/PackageCommandHandlerTest.php +++ b/tests/Handler/PackageCommandHandlerTest.php @@ -17,8 +17,8 @@ use Puli\Manager\Api\Environment; use Puli\Manager\Api\Module\InstallInfo; use Puli\Manager\Api\Module\Module; -use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Module\ModuleManager; use Puli\Manager\Api\Module\ModuleState; use Puli\Manager\Api\Module\RootModule; diff --git a/tests/Handler/TypeCommandHandlerTest.php b/tests/Handler/TypeCommandHandlerTest.php index 95854d1..57e63c9 100644 --- a/tests/Handler/TypeCommandHandlerTest.php +++ b/tests/Handler/TypeCommandHandlerTest.php @@ -19,8 +19,8 @@ use Puli\Manager\Api\Discovery\BindingTypeState; use Puli\Manager\Api\Discovery\DiscoveryManager; use Puli\Manager\Api\Module\Module; -use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Module\ModuleFile; +use Puli\Manager\Api\Module\ModuleList; use Puli\Manager\Api\Module\RootModule; use Puli\Manager\Api\Module\RootModuleFile; use Webmozart\Console\Api\Command\Command; From b82cb9b14359d924824b276e09eb26aa68fc17b8 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 29 Jul 2016 10:57:41 +0200 Subject: [PATCH 3/7] Require next beta version of manager --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index aa5b75e..179420b 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "puli/repository": "^1.0-beta9", "puli/discovery": "^1.0-beta9", "puli/url-generator": "^1.0-beta4", - "puli/manager": "^1.0-beta10", + "puli/manager": "^1.0-beta11", "webmozart/console": "^1.0-beta4", "webmozart/path-util": "^2.2.2", "webmozart/expression": "^1.0", From a62bf707f88dfcb9560edbe71455ebe0e0436f2a Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Tue, 9 Aug 2016 14:53:07 +0200 Subject: [PATCH 4/7] Fixed failing tests --- composer.json | 4 +- src/Handler/BindCommandHandler.php | 28 +- src/Handler/ConfigCommandHandler.php | 2 +- src/Handler/MapCommandHandler.php | 28 +- ...ndHandler.php => ModuleCommandHandler.php} | 110 ++--- src/Handler/PluginCommandHandler.php | 2 +- src/Handler/TypeCommandHandler.php | 22 +- src/Handler/UpgradeCommandHandler.php | 16 +- src/Proxy/DiscoveryManagerProxy.php | 8 +- src/Proxy/RepositoryManagerProxy.php | 8 +- src/PuliApplicationConfig.php | 59 +-- src/Util/ArgsUtil.php | 46 +-- tests/Handler/BindCommandHandlerTest.php | 384 +++++++++--------- .../package1 => modules/module1}/.gitkeep | 0 .../package2 => modules/module2}/.gitkeep | 0 .../package4 => modules/module4}/.gitkeep | 0 .../package5 => modules/module5}/.gitkeep | 0 tests/Handler/MapCommandHandlerTest.php | 362 ++++++++--------- ...rTest.php => ModuleCommandHandlerTest.php} | 312 +++++++------- tests/Handler/TypeCommandHandlerTest.php | 202 ++++----- tests/Handler/UpgradeCommandHandlerTest.php | 30 +- 21 files changed, 812 insertions(+), 811 deletions(-) rename src/Handler/{PackageCommandHandler.php => ModuleCommandHandler.php} (71%) rename tests/Handler/Fixtures/root/{packages/package1 => modules/module1}/.gitkeep (100%) rename tests/Handler/Fixtures/root/{packages/package2 => modules/module2}/.gitkeep (100%) rename tests/Handler/Fixtures/root/{packages/package4 => modules/module4}/.gitkeep (100%) rename tests/Handler/Fixtures/root/{packages/package5 => modules/module5}/.gitkeep (100%) rename tests/Handler/{PackageCommandHandlerTest.php => ModuleCommandHandlerTest.php} (57%) diff --git a/composer.json b/composer.json index 179420b..8c96b9a 100644 --- a/composer.json +++ b/composer.json @@ -14,12 +14,12 @@ "puli/repository": "^1.0-beta9", "puli/discovery": "^1.0-beta9", "puli/url-generator": "^1.0-beta4", - "puli/manager": "^1.0-beta11", + "puli/manager": "^1.0-beta11@dev", "webmozart/console": "^1.0-beta4", "webmozart/path-util": "^2.2.2", "webmozart/expression": "^1.0", "webmozart/glob": "^4.0", - "webmozart/json": "^1.2.2", + "webmozart/json": "^1.2.2@dev", "padraic/phar-updater": "^1.0.1" }, "require-dev": { diff --git a/src/Handler/BindCommandHandler.php b/src/Handler/BindCommandHandler.php index 6bae72f..6d6d483 100644 --- a/src/Handler/BindCommandHandler.php +++ b/src/Handler/BindCommandHandler.php @@ -56,7 +56,7 @@ class BindCommandHandler * Creates the handler. * * @param DiscoveryManager $discoveryManager The discovery manager - * @param ModuleList $modules The loaded packages + * @param ModuleList $modules The loaded modules */ public function __construct(DiscoveryManager $discoveryManager, ModuleList $modules) { @@ -74,21 +74,21 @@ public function __construct(DiscoveryManager $discoveryManager, ModuleList $modu */ public function handleList(Args $args, IO $io) { - $packageNames = ArgsUtil::getPackageNames($args, $this->modules); + $moduleNames = ArgsUtil::getModuleNames($args, $this->modules); $bindingStates = $this->getBindingStates($args); $printBindingState = count($bindingStates) > 1; - $printPackageName = count($packageNames) > 1; - $printHeaders = $printBindingState || $printPackageName; + $printModuleName = count($moduleNames) > 1; + $printHeaders = $printBindingState || $printModuleName; $printAdvice = true; - $indentation = $printBindingState && $printPackageName ? 8 - : ($printBindingState || $printPackageName ? 4 : 0); + $indentation = $printBindingState && $printModuleName ? 8 + : ($printBindingState || $printModuleName ? 4 : 0); foreach ($bindingStates as $bindingState) { $bindingStatePrinted = !$printBindingState; - foreach ($packageNames as $packageName) { - $expr = Expr::method('getContainingModule', Expr::method('getName', Expr::same($packageName))) + foreach ($moduleNames as $moduleName) { + $expr = Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($bindingState)); $descriptors = $this->discoveryManager->findBindingDescriptors($expr); @@ -104,9 +104,9 @@ public function handleList(Args $args, IO $io) $bindingStatePrinted = true; } - if ($printPackageName) { + if ($printModuleName) { $prefix = $printBindingState ? ' ' : ''; - $io->writeLine(sprintf('%sPackage: %s', $prefix, $packageName)); + $io->writeLine(sprintf('%sModule: %s', $prefix, $moduleName)); $io->writeLine(''); } @@ -183,7 +183,7 @@ public function handleUpdate(Args $args) if (!$descriptorToUpdate->getContainingModule() instanceof RootModule) { throw new RuntimeException(sprintf( - 'Can only update bindings in the package "%s".', + 'Can only update bindings in the module "%s".', $this->modules->getRootModuleName() )); } @@ -223,7 +223,7 @@ public function handleDelete(Args $args) if (!$bindingToRemove->getContainingModule() instanceof RootModule) { throw new RuntimeException(sprintf( - 'Can only delete bindings from the package "%s".', + 'Can only delete bindings from the module "%s".', $this->modules->getRootModuleName() )); } @@ -246,7 +246,7 @@ public function handleEnable(Args $args) if ($bindingToEnable->getContainingModule() instanceof RootModule) { throw new RuntimeException(sprintf( - 'Cannot enable bindings in the package "%s".', + 'Cannot enable bindings in the module "%s".', $bindingToEnable->getContainingModule()->getName() )); } @@ -269,7 +269,7 @@ public function handleDisable(Args $args) if ($bindingToDisable->getContainingModule() instanceof RootModule) { throw new RuntimeException(sprintf( - 'Cannot disable bindings in the package "%s".', + 'Cannot disable bindings in the module "%s".', $bindingToDisable->getContainingModule()->getName() )); } diff --git a/src/Handler/ConfigCommandHandler.php b/src/Handler/ConfigCommandHandler.php index 81d22fc..d073215 100644 --- a/src/Handler/ConfigCommandHandler.php +++ b/src/Handler/ConfigCommandHandler.php @@ -35,7 +35,7 @@ class ConfigCommandHandler /** * Creates the handler. * - * @param RootModuleFileManager $manager The root package file manager + * @param RootModuleFileManager $manager The root module file manager */ public function __construct(RootModuleFileManager $manager) { diff --git a/src/Handler/MapCommandHandler.php b/src/Handler/MapCommandHandler.php index 3aadb7d..4b99e40 100644 --- a/src/Handler/MapCommandHandler.php +++ b/src/Handler/MapCommandHandler.php @@ -53,7 +53,7 @@ class MapCommandHandler * Creates the handler. * * @param RepositoryManager $repoManager The repository manager - * @param ModuleList $modules The loaded packages + * @param ModuleList $modules The loaded modules */ public function __construct(RepositoryManager $repoManager, ModuleList $modules) { @@ -71,21 +71,21 @@ public function __construct(RepositoryManager $repoManager, ModuleList $modules) */ public function handleList(Args $args, IO $io) { - $packageNames = ArgsUtil::getPackageNames($args, $this->modules); + $moduleNames = ArgsUtil::getModuleNames($args, $this->modules); $states = $this->getPathMappingStates($args); $printState = count($states) > 1; - $printPackageName = count($packageNames) > 1; - $printHeaders = $printState || $printPackageName; + $printModuleName = count($moduleNames) > 1; + $printHeaders = $printState || $printModuleName; $printAdvice = true; - $indentation = ($printState && $printPackageName) ? 8 - : ($printState || $printPackageName ? 4 : 0); + $indentation = ($printState && $printModuleName) ? 8 + : ($printState || $printModuleName ? 4 : 0); foreach ($states as $state) { $statePrinted = !$printState; if (PathMappingState::CONFLICT === $state) { - $expr = Expr::method('getContainingPackage', Expr::method('getName', Expr::in($packageNames))) + $expr = Expr::method('getContainingModule', Expr::method('getName', Expr::in($moduleNames))) ->andMethod('getState', Expr::same($state)); $mappings = $this->repoManager->findPathMappings($expr); @@ -109,8 +109,8 @@ public function handleList(Args $args, IO $io) continue; } - foreach ($packageNames as $packageName) { - $expr = Expr::method('getContainingPackage', Expr::method('getName', Expr::same($packageName))) + foreach ($moduleNames as $moduleName) { + $expr = Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($state)); $mappings = $this->repoManager->findPathMappings($expr); @@ -126,9 +126,9 @@ public function handleList(Args $args, IO $io) $statePrinted = true; } - if ($printPackageName) { + if ($printModuleName) { $prefix = $printState ? ' ' : ''; - $io->writeLine(sprintf('%sPackage: %s', $prefix, $packageName)); + $io->writeLine(sprintf('%sModule: %s', $prefix, $moduleName)); $io->writeLine(''); } @@ -221,7 +221,7 @@ public function handleDelete(Args $args) if (!$this->repoManager->hasRootPathMapping($repositoryPath)) { throw new RuntimeException(sprintf( - 'The path "%s" is not mapped in the package "%s".', + 'The path "%s" is not mapped in the module "%s".', $repositoryPath, $this->modules->getRootModuleName() )); @@ -310,7 +310,7 @@ private function printConflictTable(IO $io, array $mappings, $indentation = 0) $table = new Table(PuliTableStyle::borderless()); - $table->setHeaderRow(array('Package', 'Puli Path', 'Real Path(s)')); + $table->setHeaderRow(array('Module', 'Puli Path', 'Real Path(s)')); foreach ($conflict->getMappings() as $mapping) { $table->addRow(array( @@ -372,7 +372,7 @@ private function printPathMappingStateHeader(IO $io, $pathMappingState) return; case PathMappingState::CONFLICT: $io->writeLine('Some path mappings have conflicting paths:'); - $io->writeLine(' (add the package names to the "override-order" key in puli.json to resolve)'); + $io->writeLine(' (add the module names to the "override-order" key in puli.json to resolve)'); $io->writeLine(''); return; diff --git a/src/Handler/PackageCommandHandler.php b/src/Handler/ModuleCommandHandler.php similarity index 71% rename from src/Handler/PackageCommandHandler.php rename to src/Handler/ModuleCommandHandler.php index 9f2db5c..1f5dab8 100644 --- a/src/Handler/PackageCommandHandler.php +++ b/src/Handler/ModuleCommandHandler.php @@ -26,13 +26,13 @@ use Webmozart\PathUtil\Path; /** - * Handles the "package" command. + * Handles the "module" command. * * @since 1.0 * * @author Bernhard Schussek */ -class PackageCommandHandler +class ModuleCommandHandler { /** * @var array @@ -51,7 +51,7 @@ class PackageCommandHandler /** * Creates the handler. * - * @param ModuleManager $moduleManager The package manager + * @param ModuleManager $moduleManager The module manager */ public function __construct(ModuleManager $moduleManager) { @@ -59,7 +59,7 @@ public function __construct(ModuleManager $moduleManager) } /** - * Handles the "package --list" command. + * Handles the "module --list" command. * * @param Args $args The console arguments * @param IO $io The I/O @@ -68,19 +68,19 @@ public function __construct(ModuleManager $moduleManager) */ public function handleList(Args $args, IO $io) { - $packages = $this->getSelectedPackages($args); + $modules = $this->getSelectedModules($args); if ($args->isOptionSet('format')) { - $this->printPackagesWithFormat($io, $packages, $args->getOption('format')); + $this->printModulesWithFormat($io, $modules, $args->getOption('format')); } else { - $this->printPackagesByState($io, $packages, $this->getSelectedStates($args)); + $this->printModulesByState($io, $modules, $this->getSelectedStates($args)); } return 0; } /** - * Handles the "package --install" command. + * Handles the "module --install" command. * * @param Args $args The console arguments * @@ -88,18 +88,18 @@ public function handleList(Args $args, IO $io) */ public function handleInstall(Args $args) { - $packageName = $args->getArgument('name'); + $moduleName = $args->getArgument('name'); $installPath = Path::makeAbsolute($args->getArgument('path'), getcwd()); $installer = $args->getOption('installer'); $env = $args->isOptionSet('dev') ? Environment::DEV : Environment::PROD; - $this->moduleManager->installModule($installPath, $packageName, $installer, $env); + $this->moduleManager->installModule($installPath, $moduleName, $installer, $env); return 0; } /** - * Handles the "package --rename" command. + * Handles the "module --rename" command. * * @param Args $args The console arguments * @@ -107,16 +107,16 @@ public function handleInstall(Args $args) */ public function handleRename(Args $args) { - $packageName = $args->getArgument('name'); + $moduleName = $args->getArgument('name'); $newName = $args->getArgument('new-name'); - $this->moduleManager->renameModule($packageName, $newName); + $this->moduleManager->renameModule($moduleName, $newName); return 0; } /** - * Handles the "package --delete" command. + * Handles the "module --delete" command. * * @param Args $args The console arguments * @@ -124,22 +124,22 @@ public function handleRename(Args $args) */ public function handleDelete(Args $args) { - $packageName = $args->getArgument('name'); + $moduleName = $args->getArgument('name'); - if (!$this->moduleManager->hasModule($packageName)) { + if (!$this->moduleManager->hasModule($moduleName)) { throw new RuntimeException(sprintf( - 'The package "%s" is not installed.', - $packageName + 'The module "%s" is not installed.', + $moduleName )); } - $this->moduleManager->removeModule($packageName); + $this->moduleManager->removeModule($moduleName); return 0; } /** - * Handles the "package --clean" command. + * Handles the "module --clean" command. * * @param Args $args The console arguments * @param IO $io The I/O @@ -159,7 +159,7 @@ public function handleClean(Args $args, IO $io) } /** - * Returns the package states that should be displayed for the given + * Returns the module states that should be displayed for the given * console arguments. * * @param Args $args The console arguments @@ -186,14 +186,14 @@ private function getSelectedStates(Args $args) } /** - * Returns the packages that should be displayed for the given console + * Returns the modules that should be displayed for the given console * arguments. * * @param Args $args The console arguments * - * @return ModuleList The packages + * @return ModuleList The modules */ - private function getSelectedPackages(Args $args) + private function getSelectedModules(Args $args) { $states = $this->getSelectedStates($args); $expr = Expr::true(); @@ -223,22 +223,22 @@ private function getSelectedPackages(Args $args) } /** - * Prints packages with intermediate headers for the package states. + * Prints modules with intermediate headers for the module states. * * @param IO $io The I/O - * @param ModuleList $modules The packages to print + * @param ModuleList $modules The modules to print * @param int[] $states The states to print */ - private function printPackagesByState(IO $io, ModuleList $modules, array $states) + private function printModulesByState(IO $io, ModuleList $modules, array $states) { $printStates = count($states) > 1; foreach ($states as $state) { - $filteredPackages = array_filter($modules->toArray(), function (Module $module) use ($state) { + $filteredModules = array_filter($modules->toArray(), function (Module $module) use ($state) { return $state === $module->getState(); }); - if (0 === count($filteredPackages)) { + if (0 === count($filteredModules)) { continue; } @@ -247,10 +247,10 @@ private function printPackagesByState(IO $io, ModuleList $modules, array $states } if (ModuleState::NOT_LOADABLE === $state) { - $this->printNotLoadablePackages($io, $filteredPackages, $printStates); + $this->printNotLoadableModules($io, $filteredModules, $printStates); } else { $styleTag = ModuleState::ENABLED === $state ? null : 'bad'; - $this->printPackageTable($io, $filteredPackages, $styleTag, $printStates); + $this->printModuleTable($io, $filteredModules, $styleTag, $printStates); } if ($printStates) { @@ -260,13 +260,13 @@ private function printPackagesByState(IO $io, ModuleList $modules, array $states } /** - * Prints packages using the given format. + * Prints modules using the given format. * * @param IO $io The I/O - * @param ModuleList $modules The packages to print + * @param ModuleList $modules The modules to print * @param string $format The format string */ - private function printPackagesWithFormat(IO $io, ModuleList $modules, $format) + private function printModulesWithFormat(IO $io, ModuleList $modules, $format) { /** @var Module $module */ foreach ($modules as $module) { @@ -283,7 +283,7 @@ private function printPackagesWithFormat(IO $io, ModuleList $modules, $format) } /** - * Prints the heading for a given package state. + * Prints the heading for a given module state. * * @param IO $io The I/O * @param int $ModuleState The {@link ModuleState} constant @@ -292,18 +292,18 @@ private function printModuleState(IO $io, $ModuleState) { switch ($ModuleState) { case ModuleState::ENABLED: - $io->writeLine('The following packages are currently enabled:'); + $io->writeLine('The following modules are currently enabled:'); $io->writeLine(''); return; case ModuleState::NOT_FOUND: - $io->writeLine('The following packages could not be found:'); - $io->writeLine(' (use "puli package --clean" to remove)'); + $io->writeLine('The following modules could not be found:'); + $io->writeLine(' (use "puli module --clean" to remove)'); $io->writeLine(''); return; case ModuleState::NOT_LOADABLE: - $io->writeLine('The following packages could not be loaded:'); + $io->writeLine('The following modules could not be loaded:'); $io->writeLine(''); return; @@ -311,18 +311,18 @@ private function printModuleState(IO $io, $ModuleState) } /** - * Prints a list of packages in a table. + * Prints a list of modules in a table. * * @param IO $io The I/O - * @param Module[] $modules The packages + * @param Module[] $modules The modules * @param string|null $styleTag The tag used to style the output. If `null`, * the default colors are used * @param bool $indent Whether to indent the output */ - private function printPackageTable(IO $io, array $modules, $styleTag = null, $indent = false) + private function printModuleTable(IO $io, array $modules, $styleTag = null, $indent = false) { $table = new Table(PuliTableStyle::borderless()); - $table->setHeaderRow(array('Package Name', 'Installer', 'Env', 'Install Path')); + $table->setHeaderRow(array('Module Name', 'Installer', 'Env', 'Install Path')); $installerTag = $styleTag ?: 'c1'; $envTag = $styleTag ?: 'c1'; @@ -330,15 +330,15 @@ private function printPackageTable(IO $io, array $modules, $styleTag = null, $in ksort($modules); - foreach ($modules as $package) { - $packageName = $package->getName(); - $installInfo = $package->getInstallInfo(); + foreach ($modules as $module) { + $moduleName = $module->getName(); + $installInfo = $module->getInstallInfo(); $installPath = $installInfo ? $installInfo->getInstallPath() : '.'; $installer = $installInfo ? $installInfo->getInstallerName() : ''; $env = $installInfo ? $installInfo->getEnvironment() : Environment::PROD; $table->addRow(array( - $styleTag ? sprintf('<%s>%s', $styleTag, $packageName, $styleTag) : $packageName, + $styleTag ? sprintf('<%s>%s', $styleTag, $moduleName, $styleTag) : $moduleName, $installer ? sprintf('<%s>%s', $installerTag, $installer, $installerTag) : '', sprintf('<%s>%s', $envTag, $env, $envTag), sprintf('<%s>%s', $pathTag, $installPath, $pathTag), @@ -349,23 +349,23 @@ private function printPackageTable(IO $io, array $modules, $styleTag = null, $in } /** - * Prints not-loadable packages in a table. + * Prints not-loadable modules in a table. * * @param IO $io The I/O - * @param Module[] $modules The not-loadable packages + * @param Module[] $modules The not-loadable modules * @param bool $indent Whether to indent the output */ - private function printNotLoadablePackages(IO $io, array $modules, $indent = false) + private function printNotLoadableModules(IO $io, array $modules, $indent = false) { $rootDir = $this->moduleManager->getContext()->getRootDirectory(); $table = new Table(PuliTableStyle::borderless()); - $table->setHeaderRow(array('Package Name', 'Error')); + $table->setHeaderRow(array('Module Name', 'Error')); ksort($modules); - foreach ($modules as $package) { - $packageName = $package->getName(); - $loadErrors = $package->getLoadErrors(); + foreach ($modules as $module) { + $moduleName = $module->getName(); + $loadErrors = $module->getLoadErrors(); $errorMessage = ''; foreach ($loadErrors as $loadError) { @@ -382,7 +382,7 @@ private function printNotLoadablePackages(IO $io, array $modules, $indent = fals $errorMessage = str_replace($rootDir.'/', '', $errorMessage); $table->addRow(array( - sprintf('%s', $packageName), + sprintf('%s', $moduleName), sprintf('%s', $errorMessage), )); } diff --git a/src/Handler/PluginCommandHandler.php b/src/Handler/PluginCommandHandler.php index e9ceed3..9d6b873 100644 --- a/src/Handler/PluginCommandHandler.php +++ b/src/Handler/PluginCommandHandler.php @@ -33,7 +33,7 @@ class PluginCommandHandler /** * Creates the handler. * - * @param RootModuleFileManager $manager The root package file manager + * @param RootModuleFileManager $manager The root module file manager */ public function __construct(RootModuleFileManager $manager) { diff --git a/src/Handler/TypeCommandHandler.php b/src/Handler/TypeCommandHandler.php index 1ab7663..1ea8ac0 100644 --- a/src/Handler/TypeCommandHandler.php +++ b/src/Handler/TypeCommandHandler.php @@ -49,7 +49,7 @@ class TypeCommandHandler * Creates the handler. * * @param DiscoveryManager $discoveryManager The discovery manager - * @param ModuleList $modules The loaded packages + * @param ModuleList $modules The loaded modules */ public function __construct(DiscoveryManager $discoveryManager, ModuleList $modules) { @@ -67,22 +67,22 @@ public function __construct(DiscoveryManager $discoveryManager, ModuleList $modu */ public function handleList(Args $args, IO $io) { - $packageNames = ArgsUtil::getPackageNames($args, $this->modules); + $moduleNames = ArgsUtil::getModuleNames($args, $this->modules); $states = $this->getBindingTypeStates($args); $printStates = count($states) > 1; - $printPackageName = count($packageNames) > 1; - $printHeaders = $printStates || $printPackageName; + $printModuleName = count($moduleNames) > 1; + $printHeaders = $printStates || $printModuleName; $printTypeAdvice = true; $printBindAdvice = false; - $indentation = $printStates && $printPackageName ? 8 - : ($printStates || $printPackageName ? 4 : 0); + $indentation = $printStates && $printModuleName ? 8 + : ($printStates || $printModuleName ? 4 : 0); foreach ($states as $state) { $statePrinted = !$printStates; - foreach ($packageNames as $packageName) { - $expr = Expr::method('getContainingPackage', Expr::method('getName', Expr::same($packageName))) + foreach ($moduleNames as $moduleName) { + $expr = Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($state)); $bindingTypes = $this->discoveryManager->findTypeDescriptors($expr); @@ -101,9 +101,9 @@ public function handleList(Args $args, IO $io) $printBindAdvice = true; } - if ($printPackageName) { + if ($printModuleName) { $prefix = $printStates ? ' ' : ''; - $io->writeLine("{$prefix}Package: $packageName"); + $io->writeLine("{$prefix}Module: $moduleName"); $io->writeLine(''); } @@ -203,7 +203,7 @@ public function handleDelete(Args $args) if (!$this->discoveryManager->hasRootTypeDescriptor($typeName)) { throw new RuntimeException(sprintf( - 'The type "%s" does not exist in the package "%s".', + 'The type "%s" does not exist in the module "%s".', $typeName, $this->modules->getRootModuleName() )); diff --git a/src/Handler/UpgradeCommandHandler.php b/src/Handler/UpgradeCommandHandler.php index fef45a3..e95f486 100644 --- a/src/Handler/UpgradeCommandHandler.php +++ b/src/Handler/UpgradeCommandHandler.php @@ -27,17 +27,17 @@ class UpgradeCommandHandler /** * @var RootModuleFileManager */ - private $packageFileManager; + private $moduleFileManager; /** * Creates the command handler. * - * @param RootModuleFileManager $packageFileManager The manager of the - * puli.json file + * @param RootModuleFileManager $moduleFileManager The manager of the + * puli.json file */ - public function __construct(RootModuleFileManager $packageFileManager) + public function __construct(RootModuleFileManager $moduleFileManager) { - $this->packageFileManager = $packageFileManager; + $this->moduleFileManager = $moduleFileManager; } /** @@ -50,8 +50,8 @@ public function __construct(RootModuleFileManager $packageFileManager) */ public function handle(Args $args, IO $io) { - $packageFile = $this->packageFileManager->getPackageFile(); - $originVersion = $packageFile->getVersion(); + $moduleFile = $this->moduleFileManager->getModuleFile(); + $originVersion = $moduleFile->getVersion(); $targetVersion = $args->getArgument('version'); if (version_compare($originVersion, $targetVersion, '=')) { @@ -60,7 +60,7 @@ public function handle(Args $args, IO $io) return 0; } - $this->packageFileManager->migrate($targetVersion); + $this->moduleFileManager->migrate($targetVersion); $io->writeLine(sprintf( 'Migrated your puli.json from version %s to version %s.', diff --git a/src/Proxy/DiscoveryManagerProxy.php b/src/Proxy/DiscoveryManagerProxy.php index aa8f1c9..4634959 100644 --- a/src/Proxy/DiscoveryManagerProxy.php +++ b/src/Proxy/DiscoveryManagerProxy.php @@ -126,9 +126,9 @@ public function hasRootTypeDescriptors(Expression $expr = null) /** * {@inheritdoc} */ - public function getTypeDescriptor($typeName, $packageName) + public function getTypeDescriptor($typeName, $moduleName) { - return $this->puli->getDiscoveryManager()->getTypeDescriptor($typeName, $packageName); + return $this->puli->getDiscoveryManager()->getTypeDescriptor($typeName, $moduleName); } /** @@ -150,9 +150,9 @@ public function findTypeDescriptors(Expression $expr) /** * {@inheritdoc} */ - public function hasTypeDescriptor($typeName, $packageName = null) + public function hasTypeDescriptor($typeName, $moduleName = null) { - return $this->puli->getDiscoveryManager()->hasTypeDescriptor($typeName, $packageName); + return $this->puli->getDiscoveryManager()->hasTypeDescriptor($typeName, $moduleName); } /** diff --git a/src/Proxy/RepositoryManagerProxy.php b/src/Proxy/RepositoryManagerProxy.php index 4cecca8..0918c00 100644 --- a/src/Proxy/RepositoryManagerProxy.php +++ b/src/Proxy/RepositoryManagerProxy.php @@ -132,9 +132,9 @@ public function hasRootPathMappings(Expression $expr = null) /** * {@inheritdoc} */ - public function getPathMapping($repositoryPath, $packageName) + public function getPathMapping($repositoryPath, $moduleName) { - return $this->puli->getRepositoryManager()->getPathMapping($repositoryPath, $packageName); + return $this->puli->getRepositoryManager()->getPathMapping($repositoryPath, $moduleName); } /** @@ -156,9 +156,9 @@ public function findPathMappings(Expression $expr) /** * {@inheritdoc} */ - public function hasPathMapping($repositoryPath, $packageName) + public function hasPathMapping($repositoryPath, $moduleName) { - return $this->puli->getRepositoryManager()->hasPathMapping($repositoryPath, $packageName); + return $this->puli->getRepositoryManager()->hasPathMapping($repositoryPath, $moduleName); } /** diff --git a/src/PuliApplicationConfig.php b/src/PuliApplicationConfig.php index dfe796d..3a42736 100644 --- a/src/PuliApplicationConfig.php +++ b/src/PuliApplicationConfig.php @@ -19,7 +19,7 @@ use Puli\Cli\Handler\InstallerCommandHandler; use Puli\Cli\Handler\LsCommandHandler; use Puli\Cli\Handler\MapCommandHandler; -use Puli\Cli\Handler\PackageCommandHandler; +use Puli\Cli\Handler\ModuleCommandHandler; use Puli\Cli\Handler\PluginCommandHandler; use Puli\Cli\Handler\PublishCommandHandler; use Puli\Cli\Handler\SelfUpdateCommandHandler; @@ -35,6 +35,7 @@ use Puli\Manager\Api\Module\InstallInfo; use Puli\Manager\Api\Module\ModuleFile; use Puli\Manager\Api\Server\Server; +use Puli\Manager\Module\ModuleFileConverter; use Webmozart\Console\Api\Args\Format\Argument; use Webmozart\Console\Api\Args\Format\Option; use Webmozart\Console\Api\Event\ConsoleEvents; @@ -121,14 +122,14 @@ function (PreHandleEvent $event) use ($context) { return; } - if (version_compare($moduleFile->getVersion(), ModuleFile::DEFAULT_VERSION, '<')) { + if (version_compare($moduleFile->getVersion(), ModuleFileConverter::VERSION, '<')) { $io->errorLine(sprintf( 'Warning: Your puli.json file has version %s, '. 'but the latest version is %s. Run "puli upgrade" to '. 'upgrade to %s.', $moduleFile->getVersion(), - ModuleFile::DEFAULT_VERSION, - ModuleFile::DEFAULT_VERSION + ModuleFileConverter::VERSION, + ModuleFileConverter::VERSION )); } } @@ -158,9 +159,9 @@ function (PreHandleEvent $event) use ($context) { ->beginOptionCommand('list') ->markDefault() - ->addOption('root', null, Option::NO_VALUE, 'Show bindings of the root package') - ->addOption('package', 'p', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show bindings of a package', null, 'package') - ->addOption('all', 'a', Option::NO_VALUE, 'Show bindings of all packages') + ->addOption('root', null, Option::NO_VALUE, 'Show bindings of the root module') + ->addOption('module', 'm', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show bindings of a module', null, 'module') + ->addOption('all', 'a', Option::NO_VALUE, 'Show bindings of all modules') ->addOption('enabled', null, Option::NO_VALUE, 'Show enabled bindings') ->addOption('disabled', null, Option::NO_VALUE, 'Show disabled bindings') ->addOption('type-not-found', null, Option::NO_VALUE, 'Show bindings whose type is not found') @@ -342,9 +343,9 @@ function (PreHandleEvent $event) use ($context) { ->beginOptionCommand('list') ->markDefault() - ->addOption('root', null, Option::NO_VALUE, 'Show mappings of the root package') - ->addOption('package', 'p', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show mappings of a package', null, 'package') - ->addOption('all', 'a', Option::NO_VALUE, 'Show mappings of all packages') + ->addOption('root', null, Option::NO_VALUE, 'Show mappings of the root module') + ->addOption('module', 'm', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show mappings of a module', null, 'module') + ->addOption('all', 'a', Option::NO_VALUE, 'Show mappings of all modules') ->addOption('enabled', null, Option::NO_VALUE, 'Show enabled mappings') ->addOption('not-found', null, Option::NO_VALUE, 'Show mappings whose referenced paths do not exist') ->addOption('conflict', null, Option::NO_VALUE, 'Show conflicting mappings') @@ -368,40 +369,40 @@ function (PreHandleEvent $event) use ($context) { ; $this - ->beginCommand('package') - ->setDescription('Display the installed packages') + ->beginCommand('module') + ->setDescription('Display the installed modules') ->setHandler(function () use ($puli) { - return new PackageCommandHandler($puli->getModuleManager()); + return new ModuleCommandHandler($puli->getModuleManager()); }) ->beginOptionCommand('install', 'i') - ->addArgument('path', Argument::REQUIRED, 'The path to the package') - ->addArgument('name', Argument::OPTIONAL, 'The name of the package. Taken from puli.json if not passed.') + ->addArgument('path', Argument::REQUIRED, 'The path to the module') + ->addArgument('name', Argument::OPTIONAL, 'The name of the module. Taken from puli.json if not passed.') ->addOption('installer', null, Option::REQUIRED_VALUE, 'The name of the installer', InstallInfo::DEFAULT_INSTALLER_NAME) - ->addOption('dev', null, Option::NO_VALUE, 'Install the package in the development environment') + ->addOption('dev', null, Option::NO_VALUE, 'Install the module in the development environment') ->setHandlerMethod('handleInstall') ->end() ->beginOptionCommand('list') ->markDefault() - ->addOption('installer', null, Option::REQUIRED_VALUE, 'Show packages installed by a specific installer') - ->addOption('enabled', null, Option::NO_VALUE, 'Show enabled packages') - ->addOption('not-found', null, Option::NO_VALUE, 'Show packages that could not be found') - ->addOption('not-loadable', null, Option::NO_VALUE, 'Show packages that could not be loaded') - ->addOption('dev', null, Option::NO_VALUE, 'Show packages of the development environment') - ->addOption('prod', null, Option::NO_VALUE, 'Show packages of the production environment') + ->addOption('installer', null, Option::REQUIRED_VALUE, 'Show modules installed by a specific installer') + ->addOption('enabled', null, Option::NO_VALUE, 'Show enabled modules') + ->addOption('not-found', null, Option::NO_VALUE, 'Show modules that could not be found') + ->addOption('not-loadable', null, Option::NO_VALUE, 'Show modules that could not be loaded') + ->addOption('dev', null, Option::NO_VALUE, 'Show modules of the development environment') + ->addOption('prod', null, Option::NO_VALUE, 'Show modules of the production environment') ->addOption('format', null, Option::REQUIRED_VALUE, 'The format of the output. You can use the variables %name%, %install_path%, %installer% and %state% in the format string', null, 'format') ->setHandlerMethod('handleList') ->end() ->beginOptionCommand('rename') - ->addArgument('name', Argument::REQUIRED, 'The name of the package') - ->addArgument('new-name', Argument::REQUIRED, 'The new name of the package') + ->addArgument('name', Argument::REQUIRED, 'The name of the module') + ->addArgument('new-name', Argument::REQUIRED, 'The new name of the module') ->setHandlerMethod('handleRename') ->end() ->beginOptionCommand('delete', 'd') - ->addArgument('name', Argument::REQUIRED, 'The name of the package') + ->addArgument('name', Argument::REQUIRED, 'The name of the module') ->setHandlerMethod('handleDelete') ->end() @@ -562,9 +563,9 @@ function (PreHandleEvent $event) use ($context) { ->beginSubCommand('list') ->markDefault() - ->addOption('root', null, Option::NO_VALUE, 'Show types of the root package') - ->addOption('package', 'p', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show types of a package', null, 'package') - ->addOption('all', 'a', Option::NO_VALUE, 'Show types of all packages') + ->addOption('root', null, Option::NO_VALUE, 'Show types of the root module') + ->addOption('module', 'm', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show types of a module', null, 'module') + ->addOption('all', 'a', Option::NO_VALUE, 'Show types of all modules') ->addOption('enabled', null, Option::NO_VALUE, 'Show enabled types') ->addOption('duplicate', null, Option::NO_VALUE, 'Show duplicate types') ->setHandlerMethod('handleList') @@ -589,7 +590,7 @@ function (PreHandleEvent $event) use ($context) { $this ->beginCommand('upgrade') ->setDescription('Upgrades puli.json to the newest version') - ->addArgument('version', Argument::OPTIONAL, 'The version to upgrade/downgrade to', ModuleFile::DEFAULT_VERSION) + ->addArgument('version', Argument::OPTIONAL, 'The version to upgrade/downgrade to', ModuleFileConverter::VERSION) ->setHandler(function () use ($puli) { return new UpgradeCommandHandler($puli->getRootModuleFileManager()); }) diff --git a/src/Util/ArgsUtil.php b/src/Util/ArgsUtil.php index e7917f1..8ab3d6e 100644 --- a/src/Util/ArgsUtil.php +++ b/src/Util/ArgsUtil.php @@ -24,55 +24,55 @@ class ArgsUtil { /** - * Returns the packages selected in the console arguments. + * Returns the modules selected in the console arguments. * - * @param Args $args The console arguments - * @param ModuleList $packages The available packages + * @param Args $args The console arguments + * @param ModuleList $modules The available modules * - * @return string[] The package names + * @return string[] The module names */ - public static function getPackageNames(Args $args, ModuleList $packages) + public static function getModuleNames(Args $args, ModuleList $modules) { - // Display all packages if "all" is set + // Display all modules if "all" is set if ($args->isOptionSet('all')) { - return $packages->getModuleNames(); + return $modules->getModuleNames(); } - $packageNames = array(); + $moduleNames = array(); if ($args->isOptionSet('root')) { - $packageNames[] = $packages->getRootModuleName(); + $moduleNames[] = $modules->getRootModuleName(); } - foreach ($args->getOption('package') as $packageName) { - $packageNames[] = $packageName; + foreach ($args->getOption('module') as $moduleName) { + $moduleNames[] = $moduleName; } - return $packageNames ?: $packages->getModuleNames(); + return $moduleNames ?: $modules->getModuleNames(); } /** - * Returns the non-root packages selected in the console arguments. + * Returns the non-root modules selected in the console arguments. * - * @param Args $args The console arguments - * @param ModuleList $packages The available packages + * @param Args $args The console arguments + * @param ModuleList $modules The available modules * - * @return string[] The package names + * @return string[] The module names */ - public static function getPackageNamesWithoutRoot(Args $args, ModuleList $packages) + public static function getModuleNamesWithoutRoot(Args $args, ModuleList $modules) { - // Display all packages if "all" is set + // Display all modules if "all" is set if ($args->isOptionSet('all')) { - return $packages->getInstalledModuleNames(); + return $modules->getInstalledModuleNames(); } - $packageNames = array(); + $moduleNames = array(); - foreach ($args->getOption('package') as $packageName) { - $packageNames[] = $packageName; + foreach ($args->getOption('module') as $moduleName) { + $moduleNames[] = $moduleName; } - return $packageNames ?: $packages->getInstalledModuleNames(); + return $moduleNames ?: $modules->getInstalledModuleNames(); } private function __construct() diff --git a/tests/Handler/BindCommandHandlerTest.php b/tests/Handler/BindCommandHandlerTest.php index b6014eb..67af2f8 100644 --- a/tests/Handler/BindCommandHandlerTest.php +++ b/tests/Handler/BindCommandHandlerTest.php @@ -123,8 +123,8 @@ protected function setUp() $this->discoveryManager = $this->getMock('Puli\Manager\Api\Discovery\DiscoveryManager'); $this->modules = new ModuleList(array( new RootModule(new RootModuleFile('vendor/root'), '/root'), - new Module(new ModuleFile('vendor/package1'), '/package1'), - new Module(new ModuleFile('vendor/package2'), '/package2'), + new Module(new ModuleFile('vendor/module1'), '/module1'), + new Module(new ModuleFile('vendor/module2'), '/module2'), )); $this->handler = new BindCommandHandler($this->discoveryManager, $this->modules); } @@ -138,94 +138,94 @@ public function testListAllBindings() $expected = <<<'EOF' The following bindings are currently enabled: - Package: vendor/root + Module: vendor/root UUID Glob Type bb5a07 /root/enabled Foo cc9f22 /overridden Foo 47491d BindCommandHandlerTest Bar - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 970aba /package1/enabled Foo + UUID Glob Type + 970aba /module1/enabled Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - ddb655 /package2/enabled Foo + UUID Glob Type + ddb655 /module2/enabled Foo The following bindings are disabled: (use "puli bind --enable " to enable) - Package: vendor/root + Module: vendor/root UUID Glob Type 9ac78a /root/disabled Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - a0b6c7 /package1/disabled Foo + UUID Glob Type + a0b6c7 /module1/disabled Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - 424d68 /package2/disabled Foo + UUID Glob Type + 424d68 /module2/disabled Foo The types of the following bindings could not be found: (install or create their type definitions to enable) - Package: vendor/root + Module: vendor/root UUID Glob Type d0e980 /root/type-not-found Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 19b069 /package1/type-not-found Foo + UUID Glob Type + 19b069 /module1/type-not-found Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - b7b2c3 /package2/type-not-found Foo + UUID Glob Type + b7b2c3 /module2/type-not-found Foo The types of the following bindings are not enabled: (remove the duplicate type definitions to enable) - Package: vendor/root + Module: vendor/root UUID Glob Type 47491d /root/type-not-enabled Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 7d26ae /package1/type-not-enable Foo + UUID Glob Type + 7d26ae /module1/type-not-enable Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - 53e67c /package2/type-not-enabled Foo + UUID Glob Type + 53e67c /module2/type-not-enabled Foo The following bindings have invalid parameters: (remove the binding and add again with correct parameters) - Package: vendor/root + Module: vendor/root UUID Glob Type d06707 /root/invalid Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - dd7458 /package1/invalid Foo + UUID Glob Type + dd7458 /module1/invalid Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - 24213c /package2/invalid Foo + UUID Glob Type + 24213c /module2/invalid Foo EOF; @@ -281,41 +281,41 @@ public function testListRootBindings() $this->assertEmpty($this->io->fetchErrors()); } - public function testListPackageBindings() + public function testListModuleBindings() { $this->initDefaultBindings(); - $args = self::$listCommand->parseArgs(new StringArgs('--package=vendor/package1')); + $args = self::$listCommand->parseArgs(new StringArgs('--module=vendor/module1')); $expected = <<<'EOF' The following bindings are currently enabled: - UUID Glob Type - 970aba /package1/enabled Foo + UUID Glob Type + 970aba /module1/enabled Foo The following bindings are disabled: (use "puli bind --enable " to enable) - UUID Glob Type - a0b6c7 /package1/disabled Foo + UUID Glob Type + a0b6c7 /module1/disabled Foo The types of the following bindings could not be found: (install or create their type definitions to enable) - UUID Glob Type - 19b069 /package1/type-not-found Foo + UUID Glob Type + 19b069 /module1/type-not-found Foo The types of the following bindings are not enabled: (remove the duplicate type definitions to enable) - UUID Glob Type - 7d26ae /package1/type-not-enable Foo + UUID Glob Type + 7d26ae /module1/type-not-enable Foo The following bindings have invalid parameters: (remove the binding and add again with correct parameters) - UUID Glob Type - dd7458 /package1/invalid Foo + UUID Glob Type + dd7458 /module1/invalid Foo EOF; @@ -325,78 +325,78 @@ public function testListPackageBindings() $this->assertEmpty($this->io->fetchErrors()); } - public function testListRootAndPackageBindings() + public function testListRootAndModuleBindings() { $this->initDefaultBindings(); - $args = self::$listCommand->parseArgs(new StringArgs('--root --package=vendor/package1')); + $args = self::$listCommand->parseArgs(new StringArgs('--root --module=vendor/module1')); $expected = <<<'EOF' The following bindings are currently enabled: - Package: vendor/root + Module: vendor/root UUID Glob Type bb5a07 /root/enabled Foo cc9f22 /overridden Foo 47491d BindCommandHandlerTest Bar - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 970aba /package1/enabled Foo + UUID Glob Type + 970aba /module1/enabled Foo The following bindings are disabled: (use "puli bind --enable " to enable) - Package: vendor/root + Module: vendor/root UUID Glob Type 9ac78a /root/disabled Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - a0b6c7 /package1/disabled Foo + UUID Glob Type + a0b6c7 /module1/disabled Foo The types of the following bindings could not be found: (install or create their type definitions to enable) - Package: vendor/root + Module: vendor/root UUID Glob Type d0e980 /root/type-not-found Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 19b069 /package1/type-not-found Foo + UUID Glob Type + 19b069 /module1/type-not-found Foo The types of the following bindings are not enabled: (remove the duplicate type definitions to enable) - Package: vendor/root + Module: vendor/root UUID Glob Type 47491d /root/type-not-enabled Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 7d26ae /package1/type-not-enable Foo + UUID Glob Type + 7d26ae /module1/type-not-enable Foo The following bindings have invalid parameters: (remove the binding and add again with correct parameters) - Package: vendor/root + Module: vendor/root UUID Glob Type d06707 /root/invalid Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - dd7458 /package1/invalid Foo + UUID Glob Type + dd7458 /module1/invalid Foo EOF; @@ -406,76 +406,76 @@ public function testListRootAndPackageBindings() $this->assertEmpty($this->io->fetchErrors()); } - public function testListMultiplePackageBindings() + public function testListMultipleModuleBindings() { $this->initDefaultBindings(); - $args = self::$listCommand->parseArgs(new StringArgs('--package=vendor/package1 --package=vendor/package2')); + $args = self::$listCommand->parseArgs(new StringArgs('--module=vendor/module1 --module=vendor/module2')); $expected = <<<'EOF' The following bindings are currently enabled: - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 970aba /package1/enabled Foo + UUID Glob Type + 970aba /module1/enabled Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - ddb655 /package2/enabled Foo + UUID Glob Type + ddb655 /module2/enabled Foo The following bindings are disabled: (use "puli bind --enable " to enable) - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - a0b6c7 /package1/disabled Foo + UUID Glob Type + a0b6c7 /module1/disabled Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - 424d68 /package2/disabled Foo + UUID Glob Type + 424d68 /module2/disabled Foo The types of the following bindings could not be found: (install or create their type definitions to enable) - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 19b069 /package1/type-not-found Foo + UUID Glob Type + 19b069 /module1/type-not-found Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - b7b2c3 /package2/type-not-found Foo + UUID Glob Type + b7b2c3 /module2/type-not-found Foo The types of the following bindings are not enabled: (remove the duplicate type definitions to enable) - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 7d26ae /package1/type-not-enable Foo + UUID Glob Type + 7d26ae /module1/type-not-enable Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - 53e67c /package2/type-not-enabled Foo + UUID Glob Type + 53e67c /module2/type-not-enabled Foo The following bindings have invalid parameters: (remove the binding and add again with correct parameters) - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - dd7458 /package1/invalid Foo + UUID Glob Type + dd7458 /module1/invalid Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - 24213c /package2/invalid Foo + UUID Glob Type + 24213c /module2/invalid Foo EOF; @@ -492,22 +492,22 @@ public function testListEnabledBindings() $args = self::$listCommand->parseArgs(new StringArgs('--enabled')); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root UUID Glob Type bb5a07 /root/enabled Foo cc9f22 /overridden Foo 47491d BindCommandHandlerTest Bar -Package: vendor/package1 +Module: vendor/module1 - UUID Glob Type - 970aba /package1/enabled Foo + UUID Glob Type + 970aba /module1/enabled Foo -Package: vendor/package2 +Module: vendor/module2 - UUID Glob Type - ddb655 /package2/enabled Foo + UUID Glob Type + ddb655 /module2/enabled Foo EOF; @@ -524,20 +524,20 @@ public function testListDisabledBindings() $args = self::$listCommand->parseArgs(new StringArgs('--disabled')); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root UUID Glob Type 9ac78a /root/disabled Foo -Package: vendor/package1 +Module: vendor/module1 - UUID Glob Type - a0b6c7 /package1/disabled Foo + UUID Glob Type + a0b6c7 /module1/disabled Foo -Package: vendor/package2 +Module: vendor/module2 - UUID Glob Type - 424d68 /package2/disabled Foo + UUID Glob Type + 424d68 /module2/disabled Foo EOF; @@ -554,20 +554,20 @@ public function testListBindingsWithTypeNotFound() $args = self::$listCommand->parseArgs(new StringArgs('--type-not-found')); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root UUID Glob Type d0e980 /root/type-not-found Foo -Package: vendor/package1 +Module: vendor/module1 - UUID Glob Type - 19b069 /package1/type-not-found Foo + UUID Glob Type + 19b069 /module1/type-not-found Foo -Package: vendor/package2 +Module: vendor/module2 - UUID Glob Type - b7b2c3 /package2/type-not-found Foo + UUID Glob Type + b7b2c3 /module2/type-not-found Foo EOF; @@ -584,20 +584,20 @@ public function testListBindingsWithTypeNotEnabled() $args = self::$listCommand->parseArgs(new StringArgs('--type-not-enabled')); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root UUID Glob Type 47491d /root/type-not-enabled Foo -Package: vendor/package1 +Module: vendor/module1 - UUID Glob Type - 7d26ae /package1/type-not-enable Foo + UUID Glob Type + 7d26ae /module1/type-not-enable Foo -Package: vendor/package2 +Module: vendor/module2 - UUID Glob Type - 53e67c /package2/type-not-enabled Foo + UUID Glob Type + 53e67c /module2/type-not-enabled Foo EOF; @@ -614,20 +614,20 @@ public function testListInvalidBindings() $args = self::$listCommand->parseArgs(new StringArgs('--invalid')); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root UUID Glob Type d06707 /root/invalid Foo -Package: vendor/package1 +Module: vendor/module1 - UUID Glob Type - dd7458 /package1/invalid Foo + UUID Glob Type + dd7458 /module1/invalid Foo -Package: vendor/package2 +Module: vendor/module2 - UUID Glob Type - 24213c /package2/invalid Foo + UUID Glob Type + 24213c /module2/invalid Foo EOF; @@ -646,40 +646,40 @@ public function testListEnabledAndDisabledBindings() $expected = <<<'EOF' The following bindings are currently enabled: - Package: vendor/root + Module: vendor/root UUID Glob Type bb5a07 /root/enabled Foo cc9f22 /overridden Foo 47491d BindCommandHandlerTest Bar - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - 970aba /package1/enabled Foo + UUID Glob Type + 970aba /module1/enabled Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - ddb655 /package2/enabled Foo + UUID Glob Type + ddb655 /module2/enabled Foo The following bindings are disabled: (use "puli bind --enable " to enable) - Package: vendor/root + Module: vendor/root UUID Glob Type 9ac78a /root/disabled Foo - Package: vendor/package1 + Module: vendor/module1 - UUID Glob Type - a0b6c7 /package1/disabled Foo + UUID Glob Type + a0b6c7 /module1/disabled Foo - Package: vendor/package2 + Module: vendor/module2 - UUID Glob Type - 424d68 /package2/disabled Foo + UUID Glob Type + 424d68 /module2/disabled Foo EOF; @@ -708,15 +708,15 @@ public function testListEnabledBindingsFromRoot() $this->assertEmpty($this->io->fetchErrors()); } - public function testListEnabledBindingsFromPackage() + public function testListEnabledBindingsFromModule() { $this->initDefaultBindings(); - $args = self::$listCommand->parseArgs(new StringArgs('--enabled --package=vendor/package2')); + $args = self::$listCommand->parseArgs(new StringArgs('--enabled --module=vendor/module2')); $expected = <<<'EOF' -UUID Glob Type -ddb655 /package2/enabled Foo +UUID Glob Type +ddb655 /module2/enabled Foo EOF; @@ -730,7 +730,7 @@ public function testListBindingsWithParameters() $this->discoveryManager->expects($this->any()) ->method('findBindingDescriptors') ->willReturnCallback($this->returnFromMap(array( - array($this->packageAndState('vendor/root', BindingState::ENABLED), array( + array($this->moduleAndState('vendor/root', BindingState::ENABLED), array( new BindingDescriptor(new ResourceBinding('/path', Foo::clazz, array( 'param1' => 'value1', 'param2' => 'value2', @@ -744,7 +744,7 @@ public function testListBindingsWithParameters() $expected = <<parseArgs(new StringArgs('ab12 --query /new')); $descriptor = new BindingDescriptor(new ResourceBinding('/old', Foo::clazz)); - $descriptor->load($this->modules->get('vendor/package1')); + $descriptor->load($this->modules->get('vendor/module1')); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1177,13 +1177,13 @@ public function testDeleteBindingFailsIfNotFound() /** * @expectedException \RuntimeException - * @expectedExceptionMessage Can only delete bindings from the package "vendor/root". + * @expectedExceptionMessage Can only delete bindings from the module "vendor/root". */ public function testDeleteBindingFailsIfNoRootBinding() { $args = self::$deleteCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->modules->get('vendor/package1')); + $descriptor->load($this->modules->get('vendor/module1')); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1202,7 +1202,7 @@ public function testEnableBinding() { $args = self::$enableCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->modules->get('vendor/package1')); + $descriptor->load($this->modules->get('vendor/module1')); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1237,7 +1237,7 @@ public function testEnableBindingFailsIfNotFound() /** * @expectedException \RuntimeException - * @expectedExceptionMessage Cannot enable bindings in the package "vendor/root". + * @expectedExceptionMessage Cannot enable bindings in the module "vendor/root". */ public function testEnableBindingFailsIfRoot() { @@ -1260,7 +1260,7 @@ public function testDisableBinding() { $args = self::$disableCommand->parseArgs(new StringArgs('ab12')); $descriptor = new BindingDescriptor(new ResourceBinding('/path', Foo::clazz)); - $descriptor->load($this->modules->get('vendor/package1')); + $descriptor->load($this->modules->get('vendor/module1')); $this->discoveryManager->expects($this->once()) ->method('findBindingDescriptors') @@ -1295,7 +1295,7 @@ public function testDisableBindingsFailsIfNotFound() /** * @expectedException \RuntimeException - * @expectedExceptionMessage Cannot disable bindings in the package "vendor/root". + * @expectedExceptionMessage Cannot disable bindings in the module "vendor/root". */ public function testDisableBindingFailsIfRoot() { @@ -1319,57 +1319,57 @@ private function initDefaultBindings() $this->discoveryManager->expects($this->any()) ->method('findBindingDescriptors') ->willReturnCallback($this->returnFromMap(array( - array($this->packageAndState('vendor/root', BindingState::ENABLED), array( + array($this->moduleAndState('vendor/root', BindingState::ENABLED), array( new BindingDescriptor(new ResourceBinding('/root/enabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID1))), new BindingDescriptor(new ResourceBinding('/overridden', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID2))), new BindingDescriptor(new ClassBinding(__CLASS__, Bar::clazz, array(), Uuid::fromString(self::BINDING_UUID17))), )), - array($this->packageAndState('vendor/root', BindingState::DISABLED), array( + array($this->moduleAndState('vendor/root', BindingState::DISABLED), array( new BindingDescriptor(new ResourceBinding('/root/disabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID3))), )), - array($this->packageAndState('vendor/root', BindingState::TYPE_NOT_FOUND), array( + array($this->moduleAndState('vendor/root', BindingState::TYPE_NOT_FOUND), array( new BindingDescriptor(new ResourceBinding('/root/type-not-found', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID5))), )), - array($this->packageAndState('vendor/root', BindingState::TYPE_NOT_ENABLED), array( + array($this->moduleAndState('vendor/root', BindingState::TYPE_NOT_ENABLED), array( new BindingDescriptor(new ResourceBinding('/root/type-not-enabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID17))), )), - array($this->packageAndState('vendor/root', BindingState::INVALID), array( + array($this->moduleAndState('vendor/root', BindingState::INVALID), array( new BindingDescriptor(new ResourceBinding('/root/invalid', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID6))), )), - array($this->packageAndState('vendor/package1', BindingState::ENABLED), array( - new BindingDescriptor(new ResourceBinding('/package1/enabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID7))), + array($this->moduleAndState('vendor/module1', BindingState::ENABLED), array( + new BindingDescriptor(new ResourceBinding('/module1/enabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID7))), )), - array($this->packageAndState('vendor/package1', BindingState::DISABLED), array( - new BindingDescriptor(new ResourceBinding('/package1/disabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID8))), + array($this->moduleAndState('vendor/module1', BindingState::DISABLED), array( + new BindingDescriptor(new ResourceBinding('/module1/disabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID8))), )), - array($this->packageAndState('vendor/package1', BindingState::TYPE_NOT_FOUND), array( - new BindingDescriptor(new ResourceBinding('/package1/type-not-found', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID10))), + array($this->moduleAndState('vendor/module1', BindingState::TYPE_NOT_FOUND), array( + new BindingDescriptor(new ResourceBinding('/module1/type-not-found', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID10))), )), - array($this->packageAndState('vendor/package1', BindingState::TYPE_NOT_ENABLED), array( - new BindingDescriptor(new ResourceBinding('/package1/type-not-enable', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID18))), + array($this->moduleAndState('vendor/module1', BindingState::TYPE_NOT_ENABLED), array( + new BindingDescriptor(new ResourceBinding('/module1/type-not-enable', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID18))), )), - array($this->packageAndState('vendor/package1', BindingState::INVALID), array( - new BindingDescriptor(new ResourceBinding('/package1/invalid', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID11))), + array($this->moduleAndState('vendor/module1', BindingState::INVALID), array( + new BindingDescriptor(new ResourceBinding('/module1/invalid', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID11))), )), - array($this->packageAndState('vendor/package2', BindingState::ENABLED), array( - new BindingDescriptor(new ResourceBinding('/package2/enabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID12))), + array($this->moduleAndState('vendor/module2', BindingState::ENABLED), array( + new BindingDescriptor(new ResourceBinding('/module2/enabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID12))), )), - array($this->packageAndState('vendor/package2', BindingState::DISABLED), array( - new BindingDescriptor(new ResourceBinding('/package2/disabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID13))), + array($this->moduleAndState('vendor/module2', BindingState::DISABLED), array( + new BindingDescriptor(new ResourceBinding('/module2/disabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID13))), )), - array($this->packageAndState('vendor/package2', BindingState::TYPE_NOT_FOUND), array( - new BindingDescriptor(new ResourceBinding('/package2/type-not-found', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID15))), + array($this->moduleAndState('vendor/module2', BindingState::TYPE_NOT_FOUND), array( + new BindingDescriptor(new ResourceBinding('/module2/type-not-found', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID15))), )), - array($this->packageAndState('vendor/package2', BindingState::TYPE_NOT_ENABLED), array( - new BindingDescriptor(new ResourceBinding('/package2/type-not-enabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID19))), + array($this->moduleAndState('vendor/module2', BindingState::TYPE_NOT_ENABLED), array( + new BindingDescriptor(new ResourceBinding('/module2/type-not-enabled', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID19))), )), - array($this->packageAndState('vendor/package2', BindingState::INVALID), array( - new BindingDescriptor(new ResourceBinding('/package2/invalid', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID16))), + array($this->moduleAndState('vendor/module2', BindingState::INVALID), array( + new BindingDescriptor(new ResourceBinding('/module2/invalid', Foo::clazz, array(), 'glob', Uuid::fromString(self::BINDING_UUID16))), )), ))); } - private function packageAndState($moduleName, $state) + private function moduleAndState($moduleName, $state) { return Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($state)); diff --git a/tests/Handler/Fixtures/root/packages/package1/.gitkeep b/tests/Handler/Fixtures/root/modules/module1/.gitkeep similarity index 100% rename from tests/Handler/Fixtures/root/packages/package1/.gitkeep rename to tests/Handler/Fixtures/root/modules/module1/.gitkeep diff --git a/tests/Handler/Fixtures/root/packages/package2/.gitkeep b/tests/Handler/Fixtures/root/modules/module2/.gitkeep similarity index 100% rename from tests/Handler/Fixtures/root/packages/package2/.gitkeep rename to tests/Handler/Fixtures/root/modules/module2/.gitkeep diff --git a/tests/Handler/Fixtures/root/packages/package4/.gitkeep b/tests/Handler/Fixtures/root/modules/module4/.gitkeep similarity index 100% rename from tests/Handler/Fixtures/root/packages/package4/.gitkeep rename to tests/Handler/Fixtures/root/modules/module4/.gitkeep diff --git a/tests/Handler/Fixtures/root/packages/package5/.gitkeep b/tests/Handler/Fixtures/root/modules/module5/.gitkeep similarity index 100% rename from tests/Handler/Fixtures/root/packages/package5/.gitkeep rename to tests/Handler/Fixtures/root/modules/module5/.gitkeep diff --git a/tests/Handler/MapCommandHandlerTest.php b/tests/Handler/MapCommandHandlerTest.php index 70a87c1..ae75733 100644 --- a/tests/Handler/MapCommandHandlerTest.php +++ b/tests/Handler/MapCommandHandlerTest.php @@ -62,7 +62,7 @@ class MapCommandHandlerTest extends AbstractCommandHandlerTest /** * @var ModuleList */ - private $packages; + private $modules; /** * @var MapCommandHandler @@ -84,12 +84,12 @@ protected function setUp() parent::setUp(); $this->repoManager = $this->getMock('Puli\Manager\Api\Repository\RepositoryManager'); - $this->packages = new ModuleList(array( + $this->modules = new ModuleList(array( new RootModule(new RootModuleFile('vendor/root'), '/root'), - new Module(new ModuleFile('vendor/package1'), '/package1'), - new Module(new ModuleFile('vendor/package2'), '/package2'), + new Module(new ModuleFile('vendor/module1'), '/module1'), + new Module(new ModuleFile('vendor/module2'), '/module2'), )); - $this->handler = new MapCommandHandler($this->repoManager, $this->packages); + $this->handler = new MapCommandHandler($this->repoManager, $this->modules); } public function testListAllMappings() @@ -103,57 +103,57 @@ public function testListAllMappings() $expected = <<<'EOF' The following path mappings are currently enabled: - Package: vendor/root + Module: vendor/root Puli Path Real Path(s) /root/enabled res, assets - Package: vendor/package1 + Module: vendor/module1 - Puli Path Real Path(s) - /package1/enabled res, @vendor/package2:res + Puli Path Real Path(s) + /module1/enabled res, @vendor/module2:res - Package: vendor/package2 + Module: vendor/module2 - Puli Path Real Path(s) - /package2/enabled res + Puli Path Real Path(s) + /module2/enabled res The target paths of the following path mappings were not found: - Package: vendor/root + Module: vendor/root Puli Path Real Path(s) /root/not-found res - Package: vendor/package1 + Module: vendor/module1 - Puli Path Real Path(s) - /package1/not-found res + Puli Path Real Path(s) + /module1/not-found res - Package: vendor/package2 + Module: vendor/module2 - Puli Path Real Path(s) - /package2/not-found res + Puli Path Real Path(s) + /module2/not-found res Some path mappings have conflicting paths: - (add the package names to the "override-order" key in puli.json to resolve) + (add the module names to the "override-order" key in puli.json to resolve) Conflicting path: /conflict1 Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/root /conflict1 res, assets - vendor/package1 /conflict1 res, @vendor/package2:res - vendor/package2 /conflict1 res + Module Puli Path Real Path(s) + vendor/root /conflict1 res, assets + vendor/module1 /conflict1 res, @vendor/module2:res + vendor/module2 /conflict1 res Conflicting path: /conflict2/sub/path Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/package1 /conflict2 res - vendor/package2 /conflict2 res + Module Puli Path Real Path(s) + vendor/module1 /conflict2 res + vendor/module2 /conflict2 res EOF; @@ -163,7 +163,7 @@ public function testListAllMappings() $this->assertEmpty($this->io->fetchErrors()); } - public function testListRootPackageMappings() + public function testListRootModuleMappings() { $this->initDefaultManager(); @@ -183,16 +183,16 @@ public function testListRootPackageMappings() /root/not-found res Some path mappings have conflicting paths: - (add the package names to the "override-order" key in puli.json to resolve) + (add the module names to the "override-order" key in puli.json to resolve) Conflicting path: /conflict1 Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/root /conflict1 res, assets - vendor/package1 /conflict1 res, @vendor/package2:res - vendor/package2 /conflict1 res + Module Puli Path Real Path(s) + vendor/root /conflict1 res, assets + vendor/module1 /conflict1 res, @vendor/module2:res + vendor/module2 /conflict1 res EOF; @@ -202,44 +202,44 @@ public function testListRootPackageMappings() $this->assertEmpty($this->io->fetchErrors()); } - public function testListPackageMappings() + public function testListModuleMappings() { $this->initDefaultManager(); - $args = self::$listCommand->parseArgs(new StringArgs('--package vendor/package1')); + $args = self::$listCommand->parseArgs(new StringArgs('--module vendor/module1')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' The following path mappings are currently enabled: - Puli Path Real Path(s) - /package1/enabled res, @vendor/package2:res + Puli Path Real Path(s) + /module1/enabled res, @vendor/module2:res The target paths of the following path mappings were not found: - Puli Path Real Path(s) - /package1/not-found res + Puli Path Real Path(s) + /module1/not-found res Some path mappings have conflicting paths: - (add the package names to the "override-order" key in puli.json to resolve) + (add the module names to the "override-order" key in puli.json to resolve) Conflicting path: /conflict1 Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/root /conflict1 res, assets - vendor/package1 /conflict1 res, @vendor/package2:res - vendor/package2 /conflict1 res + Module Puli Path Real Path(s) + vendor/root /conflict1 res, assets + vendor/module1 /conflict1 res, @vendor/module2:res + vendor/module2 /conflict1 res Conflicting path: /conflict2/sub/path Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/package1 /conflict2 res - vendor/package2 /conflict2 res + Module Puli Path Real Path(s) + vendor/module1 /conflict2 res + vendor/module2 /conflict2 res EOF; @@ -249,58 +249,58 @@ public function testListPackageMappings() $this->assertEmpty($this->io->fetchErrors()); } - public function testListRootAndPackageMappings() + public function testListRootAndModuleMappings() { $this->initDefaultManager(); - $args = self::$listCommand->parseArgs(new StringArgs('--root --package vendor/package1')); + $args = self::$listCommand->parseArgs(new StringArgs('--root --module vendor/module1')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' The following path mappings are currently enabled: - Package: vendor/root + Module: vendor/root Puli Path Real Path(s) /root/enabled res, assets - Package: vendor/package1 + Module: vendor/module1 - Puli Path Real Path(s) - /package1/enabled res, @vendor/package2:res + Puli Path Real Path(s) + /module1/enabled res, @vendor/module2:res The target paths of the following path mappings were not found: - Package: vendor/root + Module: vendor/root Puli Path Real Path(s) /root/not-found res - Package: vendor/package1 + Module: vendor/module1 - Puli Path Real Path(s) - /package1/not-found res + Puli Path Real Path(s) + /module1/not-found res Some path mappings have conflicting paths: - (add the package names to the "override-order" key in puli.json to resolve) + (add the module names to the "override-order" key in puli.json to resolve) Conflicting path: /conflict1 Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/root /conflict1 res, assets - vendor/package1 /conflict1 res, @vendor/package2:res - vendor/package2 /conflict1 res + Module Puli Path Real Path(s) + vendor/root /conflict1 res, assets + vendor/module1 /conflict1 res, @vendor/module2:res + vendor/module2 /conflict1 res Conflicting path: /conflict2/sub/path Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/package1 /conflict2 res - vendor/package2 /conflict2 res + Module Puli Path Real Path(s) + vendor/module1 /conflict2 res + vendor/module2 /conflict2 res EOF; @@ -310,58 +310,58 @@ public function testListRootAndPackageMappings() $this->assertEmpty($this->io->fetchErrors()); } - public function testListMultiplePackageMappings() + public function testListMultipleModuleMappings() { $this->initDefaultManager(); - $args = self::$listCommand->parseArgs(new StringArgs('--package vendor/package1 --package vendor/package2')); + $args = self::$listCommand->parseArgs(new StringArgs('--module vendor/module1 --module vendor/module2')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' The following path mappings are currently enabled: - Package: vendor/package1 + Module: vendor/module1 - Puli Path Real Path(s) - /package1/enabled res, @vendor/package2:res + Puli Path Real Path(s) + /module1/enabled res, @vendor/module2:res - Package: vendor/package2 + Module: vendor/module2 - Puli Path Real Path(s) - /package2/enabled res + Puli Path Real Path(s) + /module2/enabled res The target paths of the following path mappings were not found: - Package: vendor/package1 + Module: vendor/module1 - Puli Path Real Path(s) - /package1/not-found res + Puli Path Real Path(s) + /module1/not-found res - Package: vendor/package2 + Module: vendor/module2 - Puli Path Real Path(s) - /package2/not-found res + Puli Path Real Path(s) + /module2/not-found res Some path mappings have conflicting paths: - (add the package names to the "override-order" key in puli.json to resolve) + (add the module names to the "override-order" key in puli.json to resolve) Conflicting path: /conflict1 Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/root /conflict1 res, assets - vendor/package1 /conflict1 res, @vendor/package2:res - vendor/package2 /conflict1 res + Module Puli Path Real Path(s) + vendor/root /conflict1 res, assets + vendor/module1 /conflict1 res, @vendor/module2:res + vendor/module2 /conflict1 res Conflicting path: /conflict2/sub/path Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/package1 /conflict2 res - vendor/package2 /conflict2 res + Module Puli Path Real Path(s) + vendor/module1 /conflict2 res + vendor/module2 /conflict2 res EOF; @@ -380,20 +380,20 @@ public function testListEnabledMappings() $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root Puli Path Real Path(s) /root/enabled res, assets -Package: vendor/package1 +Module: vendor/module1 - Puli Path Real Path(s) - /package1/enabled res, @vendor/package2:res + Puli Path Real Path(s) + /module1/enabled res, @vendor/module2:res -Package: vendor/package2 +Module: vendor/module2 - Puli Path Real Path(s) - /package2/enabled res + Puli Path Real Path(s) + /module2/enabled res EOF; @@ -412,20 +412,20 @@ public function testListNotFoundMappings() $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root Puli Path Real Path(s) /root/not-found res -Package: vendor/package1 +Module: vendor/module1 - Puli Path Real Path(s) - /package1/not-found res + Puli Path Real Path(s) + /module1/not-found res -Package: vendor/package2 +Module: vendor/module2 - Puli Path Real Path(s) - /package2/not-found res + Puli Path Real Path(s) + /module2/not-found res EOF; @@ -448,18 +448,18 @@ public function testListConflictingMappings() Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/root /conflict1 res, assets - vendor/package1 /conflict1 res, @vendor/package2:res - vendor/package2 /conflict1 res + Module Puli Path Real Path(s) + vendor/root /conflict1 res, assets + vendor/module1 /conflict1 res, @vendor/module2:res + vendor/module2 /conflict1 res Conflicting path: /conflict2/sub/path Mapped by the following mappings: - Package Puli Path Real Path(s) - vendor/package1 /conflict2 res - vendor/package2 /conflict2 res + Module Puli Path Real Path(s) + vendor/module1 /conflict2 res + vendor/module2 /conflict2 res EOF; @@ -480,37 +480,37 @@ public function testListEnabledAndNotFoundMappings() $expected = <<<'EOF' The following path mappings are currently enabled: - Package: vendor/root + Module: vendor/root Puli Path Real Path(s) /root/enabled res, assets - Package: vendor/package1 + Module: vendor/module1 - Puli Path Real Path(s) - /package1/enabled res, @vendor/package2:res + Puli Path Real Path(s) + /module1/enabled res, @vendor/module2:res - Package: vendor/package2 + Module: vendor/module2 - Puli Path Real Path(s) - /package2/enabled res + Puli Path Real Path(s) + /module2/enabled res The target paths of the following path mappings were not found: - Package: vendor/root + Module: vendor/root Puli Path Real Path(s) /root/not-found res - Package: vendor/package1 + Module: vendor/module1 - Puli Path Real Path(s) - /package1/not-found res + Puli Path Real Path(s) + /module1/not-found res - Package: vendor/package2 + Module: vendor/module2 - Puli Path Real Path(s) - /package2/not-found res + Puli Path Real Path(s) + /module2/not-found res EOF; @@ -539,17 +539,17 @@ public function testListEnabledMappingsFromRoot() $this->assertEmpty($this->io->fetchErrors()); } - public function testListEnabledMappingsFromPackage() + public function testListEnabledMappingsFromModule() { $this->initDefaultManager(); - $args = self::$listCommand->parseArgs(new StringArgs('--enabled --package vendor/package1')); + $args = self::$listCommand->parseArgs(new StringArgs('--enabled --module vendor/module1')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -Puli Path Real Path(s) -/package1/enabled res, @vendor/package2:res +Puli Path Real Path(s) +/module1/enabled res, @vendor/module2:res EOF; @@ -616,7 +616,7 @@ public function testUpdateMappingAddPathReferences() $args = self::$updateCommand->parseArgs(new StringArgs('/path --add assets --add res')); $mapping = new PathMapping('/path', array('previous')); - $mapping->load($this->packages->getRootModule(), $this->packages); + $mapping->load($this->modules->getRootModule(), $this->modules); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -635,7 +635,7 @@ public function testUpdateMappingRemovePathReference() $args = self::$updateCommand->parseArgs(new StringArgs('/path --remove assets')); $mapping = new PathMapping('/path', array('assets', 'res')); - $mapping->load($this->packages->getRootModule(), $this->packages); + $mapping->load($this->modules->getRootModule(), $this->modules); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -654,7 +654,7 @@ public function testUpdateMappingRemoveAllPathReferences() $args = self::$updateCommand->parseArgs(new StringArgs('/path --remove assets --remove res')); $mapping = new PathMapping('/path', array('assets', 'res')); - $mapping->load($this->packages->getRootModule(), $this->packages); + $mapping->load($this->modules->getRootModule(), $this->modules); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -673,7 +673,7 @@ public function testUpdateMappingRelativePath() $args = self::$updateCommand->parseArgs(new StringArgs('rel --add assets')); $mapping = new PathMapping('/rel', array('previous')); - $mapping->load($this->packages->getRootModule(), $this->packages); + $mapping->load($this->modules->getRootModule(), $this->modules); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -692,7 +692,7 @@ public function testUpdateMappingForce() $args = self::$updateCommand->parseArgs(new StringArgs('/path --add assets --force')); $mapping = new PathMapping('/path', array('previous')); - $mapping->load($this->packages->getRootModule(), $this->packages); + $mapping->load($this->modules->getRootModule(), $this->modules); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -714,7 +714,7 @@ public function testUpdateMappingFailsIfNoChange() $args = self::$updateCommand->parseArgs(new StringArgs('/path')); $mapping = new PathMapping('/path', array('previous')); - $mapping->load($this->packages->getRootModule(), $this->packages); + $mapping->load($this->modules->getRootModule(), $this->modules); $this->repoManager->expects($this->once()) ->method('getRootPathMapping') @@ -761,7 +761,7 @@ public function testDeleteMappingWithAbsolutePath() /** * @expectedException \RuntimeException - * @expectedExceptionMessage The path "/path1" is not mapped in the package "vendor/root". + * @expectedExceptionMessage The path "/path1" is not mapped in the module "vendor/root". */ public function testDeleteMappingFailsIfNotFound() { @@ -782,95 +782,95 @@ public function testDeleteMappingFailsIfNotFound() private function initDefaultManager() { $conflictMappingRoot1 = new PathMapping('/conflict1', array('res', 'assets')); - $conflictMappingPackage11 = new PathMapping('/conflict1', array('res', '@vendor/package2:res')); - $conflictMappingPackage12 = new PathMapping('/conflict2', 'res'); - $conflictMappingPackage21 = new PathMapping('/conflict1', 'res'); - $conflictMappingPackage22 = new PathMapping('/conflict2', 'res'); + $conflictMappingModule11 = new PathMapping('/conflict1', array('res', '@vendor/module2:res')); + $conflictMappingModule12 = new PathMapping('/conflict2', 'res'); + $conflictMappingModule21 = new PathMapping('/conflict1', 'res'); + $conflictMappingModule22 = new PathMapping('/conflict2', 'res'); - $conflictMappingRoot1->load($this->packages->getRootModule(), $this->packages); - $conflictMappingPackage11->load($this->packages->get('vendor/package1'), $this->packages); - $conflictMappingPackage12->load($this->packages->get('vendor/package1'), $this->packages); - $conflictMappingPackage21->load($this->packages->get('vendor/package2'), $this->packages); - $conflictMappingPackage22->load($this->packages->get('vendor/package2'), $this->packages); + $conflictMappingRoot1->load($this->modules->getRootModule(), $this->modules); + $conflictMappingModule11->load($this->modules->get('vendor/module1'), $this->modules); + $conflictMappingModule12->load($this->modules->get('vendor/module1'), $this->modules); + $conflictMappingModule21->load($this->modules->get('vendor/module2'), $this->modules); + $conflictMappingModule22->load($this->modules->get('vendor/module2'), $this->modules); $conflict1 = new PathConflict('/conflict1'); $conflict1->addMappings(array( $conflictMappingRoot1, - $conflictMappingPackage11, - $conflictMappingPackage21, + $conflictMappingModule11, + $conflictMappingModule21, )); $conflict2 = new PathConflict('/conflict2/sub/path'); $conflict2->addMappings(array( - $conflictMappingPackage12, - $conflictMappingPackage22, + $conflictMappingModule12, + $conflictMappingModule22, )); $this->repoManager->expects($this->any()) ->method('findPathMappings') ->willReturnCallback($this->returnFromMap(array( - array($this->packageAndState('vendor/root', PathMappingState::ENABLED), array( + array($this->moduleAndState('vendor/root', PathMappingState::ENABLED), array( new PathMapping('/root/enabled', array('res', 'assets')), )), - array($this->packageAndState('vendor/package1', PathMappingState::ENABLED), array( - new PathMapping('/package1/enabled', array('res', '@vendor/package2:res')), + array($this->moduleAndState('vendor/module1', PathMappingState::ENABLED), array( + new PathMapping('/module1/enabled', array('res', '@vendor/module2:res')), )), - array($this->packageAndState('vendor/package2', PathMappingState::ENABLED), array( - new PathMapping('/package2/enabled', 'res'), + array($this->moduleAndState('vendor/module2', PathMappingState::ENABLED), array( + new PathMapping('/module2/enabled', 'res'), )), - array($this->packageAndState('vendor/root', PathMappingState::NOT_FOUND), array( + array($this->moduleAndState('vendor/root', PathMappingState::NOT_FOUND), array( new PathMapping('/root/not-found', 'res'), )), - array($this->packageAndState('vendor/package1', PathMappingState::NOT_FOUND), array( - new PathMapping('/package1/not-found', 'res'), + array($this->moduleAndState('vendor/module1', PathMappingState::NOT_FOUND), array( + new PathMapping('/module1/not-found', 'res'), )), - array($this->packageAndState('vendor/package2', PathMappingState::NOT_FOUND), array( - new PathMapping('/package2/not-found', 'res'), + array($this->moduleAndState('vendor/module2', PathMappingState::NOT_FOUND), array( + new PathMapping('/module2/not-found', 'res'), )), - array($this->packagesAndState(array('vendor/root'), PathMappingState::CONFLICT), array( + array($this->modulesAndState(array('vendor/root'), PathMappingState::CONFLICT), array( $conflictMappingRoot1, )), - array($this->packagesAndState(array('vendor/package1'), PathMappingState::CONFLICT), array( - $conflictMappingPackage11, - $conflictMappingPackage12, + array($this->modulesAndState(array('vendor/module1'), PathMappingState::CONFLICT), array( + $conflictMappingModule11, + $conflictMappingModule12, )), - array($this->packagesAndState(array('vendor/package2'), PathMappingState::CONFLICT), array( - $conflictMappingPackage21, - $conflictMappingPackage22, + array($this->modulesAndState(array('vendor/module2'), PathMappingState::CONFLICT), array( + $conflictMappingModule21, + $conflictMappingModule22, )), - array($this->packagesAndState(array('vendor/root', 'vendor/package1'), PathMappingState::CONFLICT), array( + array($this->modulesAndState(array('vendor/root', 'vendor/module1'), PathMappingState::CONFLICT), array( $conflictMappingRoot1, - $conflictMappingPackage11, - $conflictMappingPackage12, + $conflictMappingModule11, + $conflictMappingModule12, )), - array($this->packagesAndState(array('vendor/root', 'vendor/package2'), PathMappingState::CONFLICT), array( + array($this->modulesAndState(array('vendor/root', 'vendor/module2'), PathMappingState::CONFLICT), array( $conflictMappingRoot1, - $conflictMappingPackage21, - $conflictMappingPackage22, + $conflictMappingModule21, + $conflictMappingModule22, )), - array($this->packagesAndState(array('vendor/package1', 'vendor/package2'), PathMappingState::CONFLICT), array( - $conflictMappingPackage11, - $conflictMappingPackage12, - $conflictMappingPackage21, - $conflictMappingPackage22, + array($this->modulesAndState(array('vendor/module1', 'vendor/module2'), PathMappingState::CONFLICT), array( + $conflictMappingModule11, + $conflictMappingModule12, + $conflictMappingModule21, + $conflictMappingModule22, )), - array($this->packagesAndState(array('vendor/root', 'vendor/package1', 'vendor/package2'), PathMappingState::CONFLICT), array( + array($this->modulesAndState(array('vendor/root', 'vendor/module1', 'vendor/module2'), PathMappingState::CONFLICT), array( $conflictMappingRoot1, - $conflictMappingPackage11, - $conflictMappingPackage12, - $conflictMappingPackage21, - $conflictMappingPackage22, + $conflictMappingModule11, + $conflictMappingModule12, + $conflictMappingModule21, + $conflictMappingModule22, )), ))); } - private function packageAndState($moduleName, $state) + private function moduleAndState($moduleName, $state) { return Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($state)); } - private function packagesAndState(array $moduleNames, $state) + private function modulesAndState(array $moduleNames, $state) { return Expr::method('getContainingModule', Expr::method('getName', Expr::in($moduleNames))) ->andMethod('getState', Expr::same($state)); diff --git a/tests/Handler/PackageCommandHandlerTest.php b/tests/Handler/ModuleCommandHandlerTest.php similarity index 57% rename from tests/Handler/PackageCommandHandlerTest.php rename to tests/Handler/ModuleCommandHandlerTest.php index 90a5d51..a3ce35d 100644 --- a/tests/Handler/PackageCommandHandlerTest.php +++ b/tests/Handler/ModuleCommandHandlerTest.php @@ -12,7 +12,7 @@ namespace Puli\Cli\Tests\Handler; use PHPUnit_Framework_MockObject_MockObject; -use Puli\Cli\Handler\PackageCommandHandler; +use Puli\Cli\Handler\ModuleCommandHandler; use Puli\Manager\Api\Context\ProjectContext; use Puli\Manager\Api\Environment; use Puli\Manager\Api\Module\InstallInfo; @@ -35,7 +35,7 @@ * * @author Bernhard Schussek */ -class PackageCommandHandlerTest extends AbstractCommandHandlerTest +class ModuleCommandHandlerTest extends AbstractCommandHandlerTest { /** * @var Command @@ -70,10 +70,10 @@ class PackageCommandHandlerTest extends AbstractCommandHandlerTest /** * @var PHPUnit_Framework_MockObject_MockObject|ModuleManager */ - private $packageManager; + private $moduleManager; /** - * @var PackageCommandHandler + * @var ModuleCommandHandler */ private $handler; @@ -91,11 +91,11 @@ public static function setUpBeforeClass() { parent::setUpBeforeClass(); - self::$listCommand = self::$application->getCommand('package')->getSubCommand('list'); - self::$installCommand = self::$application->getCommand('package')->getSubCommand('install'); - self::$renameCommand = self::$application->getCommand('package')->getSubCommand('rename'); - self::$deleteCommand = self::$application->getCommand('package')->getSubCommand('delete'); - self::$cleanCommand = self::$application->getCommand('package')->getSubCommand('clean'); + self::$listCommand = self::$application->getCommand('module')->getSubCommand('list'); + self::$installCommand = self::$application->getCommand('module')->getSubCommand('install'); + self::$renameCommand = self::$application->getCommand('module')->getSubCommand('rename'); + self::$deleteCommand = self::$application->getCommand('module')->getSubCommand('delete'); + self::$cleanCommand = self::$application->getCommand('module')->getSubCommand('clean'); } protected function setUp() @@ -105,22 +105,22 @@ protected function setUp() $this->context = $this->getMockBuilder('Puli\Manager\Api\Context\ProjectContext') ->disableOriginalConstructor() ->getMock(); - $this->packageManager = $this->getMock('Puli\Manager\Api\Module\ModuleManager'); - $this->handler = new PackageCommandHandler($this->packageManager); + $this->moduleManager = $this->getMock('Puli\Manager\Api\Module\ModuleManager'); + $this->handler = new ModuleCommandHandler($this->moduleManager); $this->context->expects($this->any()) ->method('getRootDirectory') ->willReturn(__DIR__.'/Fixtures/root'); - $this->packageManager->expects($this->any()) + $this->moduleManager->expects($this->any()) ->method('getContext') ->willReturn($this->context); - $installInfo1 = new InstallInfo('vendor/package1', 'packages/package1'); - $installInfo2 = new InstallInfo('vendor/package2', 'packages/package2'); - $installInfo3 = new InstallInfo('vendor/package3', 'packages/package3'); - $installInfo4 = new InstallInfo('vendor/package4', 'packages/package4'); - $installInfo5 = new InstallInfo('vendor/package5', 'packages/package5'); + $installInfo1 = new InstallInfo('vendor/module1', 'modules/module1'); + $installInfo2 = new InstallInfo('vendor/module2', 'modules/module2'); + $installInfo3 = new InstallInfo('vendor/module3', 'modules/module3'); + $installInfo4 = new InstallInfo('vendor/module4', 'modules/module4'); + $installInfo5 = new InstallInfo('vendor/module5', 'modules/module5'); $installInfo1->setInstallerName('spock'); $installInfo2->setInstallerName('spock'); @@ -130,27 +130,27 @@ protected function setUp() $installInfo5->setEnvironment(Environment::DEV); $rootModule = new RootModule(new RootModuleFile('vendor/root'), __DIR__.'/Fixtures/root'); - $package1 = new Module(new ModuleFile('vendor/package1'), __DIR__.'/Fixtures/root/packages/package1', $installInfo1); - $package2 = new Module(new ModuleFile('vendor/package2'), __DIR__.'/Fixtures/root/packages/package2', $installInfo2); - $package3 = new Module(new ModuleFile('vendor/package3'), __DIR__.'/Fixtures/root/packages/package3', $installInfo3); - $package4 = new Module(null, __DIR__.'/Fixtures/root/packages/package4', $installInfo4, array(new RuntimeException('Load error'))); - $package5 = new Module(new ModuleFile('vendor/package5'), __DIR__.'/Fixtures/root/packages/package5', $installInfo5); + $module1 = new Module(new ModuleFile('vendor/module1'), __DIR__.'/Fixtures/root/modules/module1', $installInfo1); + $module2 = new Module(new ModuleFile('vendor/module2'), __DIR__.'/Fixtures/root/modules/module2', $installInfo2); + $module3 = new Module(new ModuleFile('vendor/module3'), __DIR__.'/Fixtures/root/modules/module3', $installInfo3); + $module4 = new Module(null, __DIR__.'/Fixtures/root/modules/module4', $installInfo4, array(new RuntimeException('Load error'))); + $module5 = new Module(new ModuleFile('vendor/module5'), __DIR__.'/Fixtures/root/modules/module5', $installInfo5); - $this->packageManager->expects($this->any()) + $this->moduleManager->expects($this->any()) ->method('findModules') ->willReturnCallback($this->returnFromMap(array( - array($this->all(), new ModuleList(array($rootModule, $package1, $package2, $package3, $package4, $package5))), - array($this->env(array(Environment::PROD, Environment::DEV)), new ModuleList(array($rootModule, $package1, $package2, $package3, $package4, $package5))), - array($this->env(array(Environment::PROD)), new ModuleList(array($rootModule, $package1, $package2, $package3, $package4))), - array($this->env(array(Environment::DEV)), new ModuleList(array($package5))), - array($this->installer('spock'), new ModuleList(array($package1, $package2, $package4, $package5))), - array($this->state(ModuleState::ENABLED), new ModuleList(array($rootModule, $package1, $package2, $package5))), - array($this->state(ModuleState::NOT_FOUND), new ModuleList(array($package3))), - array($this->state(ModuleState::NOT_LOADABLE), new ModuleList(array($package4))), - array($this->states(array(ModuleState::ENABLED, ModuleState::NOT_FOUND)), new ModuleList(array($rootModule, $package1, $package2, $package3, $package5))), - array($this->installerAndState('spock', ModuleState::ENABLED), new ModuleList(array($package1, $package2, $package5))), + array($this->all(), new ModuleList(array($rootModule, $module1, $module2, $module3, $module4, $module5))), + array($this->env(array(Environment::PROD, Environment::DEV)), new ModuleList(array($rootModule, $module1, $module2, $module3, $module4, $module5))), + array($this->env(array(Environment::PROD)), new ModuleList(array($rootModule, $module1, $module2, $module3, $module4))), + array($this->env(array(Environment::DEV)), new ModuleList(array($module5))), + array($this->installer('spock'), new ModuleList(array($module1, $module2, $module4, $module5))), + array($this->state(ModuleState::ENABLED), new ModuleList(array($rootModule, $module1, $module2, $module5))), + array($this->state(ModuleState::NOT_FOUND), new ModuleList(array($module3))), + array($this->state(ModuleState::NOT_LOADABLE), new ModuleList(array($module4))), + array($this->states(array(ModuleState::ENABLED, ModuleState::NOT_FOUND)), new ModuleList(array($rootModule, $module1, $module2, $module3, $module5))), + array($this->installerAndState('spock', ModuleState::ENABLED), new ModuleList(array($module1, $module2, $module5))), array($this->installerAndState('spock', ModuleState::NOT_FOUND), new ModuleList(array())), - array($this->installerAndState('spock', ModuleState::NOT_LOADABLE), new ModuleList(array($package4))), + array($this->installerAndState('spock', ModuleState::NOT_LOADABLE), new ModuleList(array($module4))), ))); $this->previousWd = getcwd(); @@ -164,31 +164,31 @@ protected function tearDown() chdir($this->previousWd); } - public function testListPackages() + public function testListModules() { $args = self::$listCommand->parseArgs(new StringArgs('')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -The following packages are currently enabled: +The following modules are currently enabled: - Package Name Installer Env Install Path - vendor/package1 spock prod packages/package1 - vendor/package2 spock prod packages/package2 - vendor/package5 spock dev packages/package5 - vendor/root prod . + Module Name Installer Env Install Path + vendor/module1 spock prod modules/module1 + vendor/module2 spock prod modules/module2 + vendor/module5 spock dev modules/module5 + vendor/root prod . -The following packages could not be found: - (use "puli package --clean" to remove) +The following modules could not be found: + (use "puli module --clean" to remove) - Package Name Installer Env Install Path - vendor/package3 kirk prod packages/package3 + Module Name Installer Env Install Path + vendor/module3 kirk prod modules/module3 -The following packages could not be loaded: +The following modules could not be loaded: - Package Name Error - vendor/package4 RuntimeException: Load error + Module Name Error + vendor/module4 RuntimeException: Load error EOF; @@ -198,24 +198,24 @@ public function testListPackages() $this->assertEmpty($this->io->fetchErrors()); } - public function testListPackagesByInstaller() + public function testListModulesByInstaller() { $args = self::$listCommand->parseArgs(new StringArgs('--installer spock')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -The following packages are currently enabled: +The following modules are currently enabled: - Package Name Installer Env Install Path - vendor/package1 spock prod packages/package1 - vendor/package2 spock prod packages/package2 - vendor/package5 spock dev packages/package5 + Module Name Installer Env Install Path + vendor/module1 spock prod modules/module1 + vendor/module2 spock prod modules/module2 + vendor/module5 spock dev modules/module5 -The following packages could not be loaded: +The following modules could not be loaded: - Package Name Error - vendor/package4 RuntimeException: Load error + Module Name Error + vendor/module4 RuntimeException: Load error EOF; @@ -225,18 +225,18 @@ public function testListPackagesByInstaller() $this->assertEmpty($this->io->fetchErrors()); } - public function testListEnabledPackages() + public function testListEnabledModules() { $args = self::$listCommand->parseArgs(new StringArgs('--enabled')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -Package Name Installer Env Install Path -vendor/package1 spock prod packages/package1 -vendor/package2 spock prod packages/package2 -vendor/package5 spock dev packages/package5 -vendor/root prod . +Module Name Installer Env Install Path +vendor/module1 spock prod modules/module1 +vendor/module2 spock prod modules/module2 +vendor/module5 spock dev modules/module5 +vendor/root prod . EOF; @@ -245,15 +245,15 @@ public function testListEnabledPackages() $this->assertEmpty($this->io->fetchErrors()); } - public function testListNotFoundPackages() + public function testListNotFoundModules() { $args = self::$listCommand->parseArgs(new StringArgs('--not-found')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -Package Name Installer Env Install Path -vendor/package3 kirk prod packages/package3 +Module Name Installer Env Install Path +vendor/module3 kirk prod modules/module3 EOF; @@ -262,15 +262,15 @@ public function testListNotFoundPackages() $this->assertEmpty($this->io->fetchErrors()); } - public function testListNotLoadablePackages() + public function testListNotLoadableModules() { $args = self::$listCommand->parseArgs(new StringArgs('--not-loadable')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -Package Name Error -vendor/package4 RuntimeException: Load error +Module Name Error +vendor/module4 RuntimeException: Load error EOF; @@ -279,26 +279,26 @@ public function testListNotLoadablePackages() $this->assertEmpty($this->io->fetchErrors()); } - public function testListEnabledAndNotFoundPackages() + public function testListEnabledAndNotFoundModules() { $args = self::$listCommand->parseArgs(new StringArgs('--enabled --not-found')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -The following packages are currently enabled: +The following modules are currently enabled: - Package Name Installer Env Install Path - vendor/package1 spock prod packages/package1 - vendor/package2 spock prod packages/package2 - vendor/package5 spock dev packages/package5 - vendor/root prod . + Module Name Installer Env Install Path + vendor/module1 spock prod modules/module1 + vendor/module2 spock prod modules/module2 + vendor/module5 spock dev modules/module5 + vendor/root prod . -The following packages could not be found: - (use "puli package --clean" to remove) +The following modules could not be found: + (use "puli module --clean" to remove) - Package Name Installer Env Install Path - vendor/package3 kirk prod packages/package3 + Module Name Installer Env Install Path + vendor/module3 kirk prod modules/module3 EOF; @@ -308,17 +308,17 @@ public function testListEnabledAndNotFoundPackages() $this->assertEmpty($this->io->fetchErrors()); } - public function testListEnabledPackagesByInstaller() + public function testListEnabledModulesByInstaller() { $args = self::$listCommand->parseArgs(new StringArgs('--enabled --installer spock')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -Package Name Installer Env Install Path -vendor/package1 spock prod packages/package1 -vendor/package2 spock prod packages/package2 -vendor/package5 spock dev packages/package5 +Module Name Installer Env Install Path +vendor/module1 spock prod modules/module1 +vendor/module2 spock prod modules/module2 +vendor/module5 spock dev modules/module5 EOF; @@ -327,17 +327,17 @@ public function testListEnabledPackagesByInstaller() $this->assertEmpty($this->io->fetchErrors()); } - public function testListDevPackages() + public function testListDevModules() { $args = self::$listCommand->parseArgs(new StringArgs('--dev')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -The following packages are currently enabled: +The following modules are currently enabled: - Package Name Installer Env Install Path - vendor/package5 spock dev packages/package5 + Module Name Installer Env Install Path + vendor/module5 spock dev modules/module5 EOF; @@ -347,30 +347,30 @@ public function testListDevPackages() $this->assertEmpty($this->io->fetchErrors()); } - public function testListNoDevPackages() + public function testListNoDevModules() { $args = self::$listCommand->parseArgs(new StringArgs('--prod')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -The following packages are currently enabled: +The following modules are currently enabled: - Package Name Installer Env Install Path - vendor/package1 spock prod packages/package1 - vendor/package2 spock prod packages/package2 - vendor/root prod . + Module Name Installer Env Install Path + vendor/module1 spock prod modules/module1 + vendor/module2 spock prod modules/module2 + vendor/root prod . -The following packages could not be found: - (use "puli package --clean" to remove) +The following modules could not be found: + (use "puli module --clean" to remove) - Package Name Installer Env Install Path - vendor/package3 kirk prod packages/package3 + Module Name Installer Env Install Path + vendor/module3 kirk prod modules/module3 -The following packages could not be loaded: +The following modules could not be loaded: - Package Name Error - vendor/package4 RuntimeException: Load error + Module Name Error + vendor/module4 RuntimeException: Load error EOF; @@ -380,34 +380,34 @@ public function testListNoDevPackages() $this->assertEmpty($this->io->fetchErrors()); } - public function testListDevAndNoDevPackages() + public function testListDevAndNoDevModules() { // Same as if passing none of the too // Does not make much sense but could occur if building the - // "package list" command dynamically + // "module list" command dynamically $args = self::$listCommand->parseArgs(new StringArgs('--dev --prod')); $statusCode = $this->handler->handleList($args, $this->io); $expected = <<<'EOF' -The following packages are currently enabled: +The following modules are currently enabled: - Package Name Installer Env Install Path - vendor/package1 spock prod packages/package1 - vendor/package2 spock prod packages/package2 - vendor/package5 spock dev packages/package5 - vendor/root prod . + Module Name Installer Env Install Path + vendor/module1 spock prod modules/module1 + vendor/module2 spock prod modules/module2 + vendor/module5 spock dev modules/module5 + vendor/root prod . -The following packages could not be found: - (use "puli package --clean" to remove) +The following modules could not be found: + (use "puli module --clean" to remove) - Package Name Installer Env Install Path - vendor/package3 kirk prod packages/package3 + Module Name Installer Env Install Path + vendor/module3 kirk prod modules/module3 -The following packages could not be loaded: +The following modules could not be loaded: - Package Name Error - vendor/package4 RuntimeException: Load error + Module Name Error + vendor/module4 RuntimeException: Load error EOF; @@ -417,7 +417,7 @@ public function testListDevAndNoDevPackages() $this->assertEmpty($this->io->fetchErrors()); } - public function testListPackagesWithFormat() + public function testListModulesWithFormat() { $args = self::$listCommand->parseArgs(new StringArgs('--format %name%:%installer%:%install_path%:%state%:%env%')); @@ -426,11 +426,11 @@ public function testListPackagesWithFormat() $expected = <<parseArgs(new StringArgs('packages/package1')); + $args = self::$installCommand->parseArgs(new StringArgs('modules/module1')); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('installModule') - ->with($this->wd.'/packages/package1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); + ->with($this->wd.'/modules/module1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); $this->assertSame(0, $this->handler->handleInstall($args)); } public function testInstallModuleWithAbsolutePath() { - $args = self::$installCommand->parseArgs(new StringArgs('/packages/package1')); + $args = self::$installCommand->parseArgs(new StringArgs('/modules/module1')); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('installModule') - ->with('/packages/package1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); + ->with('/modules/module1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); $this->assertSame(0, $this->handler->handleInstall($args)); } public function testInstallModuleWithCustomName() { - $args = self::$installCommand->parseArgs(new StringArgs('/packages/package1 custom/package1')); + $args = self::$installCommand->parseArgs(new StringArgs('/modules/module1 custom/module1')); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('installModule') - ->with('/packages/package1', 'custom/package1', InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); + ->with('/modules/module1', 'custom/module1', InstallInfo::DEFAULT_INSTALLER_NAME, Environment::PROD); $this->assertSame(0, $this->handler->handleInstall($args)); } public function testInstallModuleWithCustomInstaller() { - $args = self::$installCommand->parseArgs(new StringArgs('--installer kirk /packages/package1')); + $args = self::$installCommand->parseArgs(new StringArgs('--installer kirk /modules/module1')); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('installModule') - ->with('/packages/package1', null, 'kirk', Environment::PROD); + ->with('/modules/module1', null, 'kirk', Environment::PROD); $this->assertSame(0, $this->handler->handleInstall($args)); } public function testInstallDevModule() { - $args = self::$installCommand->parseArgs(new StringArgs('--dev packages/package1')); + $args = self::$installCommand->parseArgs(new StringArgs('--dev modules/module1')); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('installModule') - ->with($this->wd.'/packages/package1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::DEV); + ->with($this->wd.'/modules/module1', null, InstallInfo::DEFAULT_INSTALLER_NAME, Environment::DEV); $this->assertSame(0, $this->handler->handleInstall($args)); } public function testRenameModule() { - $args = self::$renameCommand->parseArgs(new StringArgs('vendor/package1 vendor/new')); + $args = self::$renameCommand->parseArgs(new StringArgs('vendor/module1 vendor/new')); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('renameModule') - ->with('vendor/package1', 'vendor/new'); + ->with('vendor/module1', 'vendor/new'); $this->assertSame(0, $this->handler->handleRename($args)); } public function testDeleteModule() { - $args = self::$deleteCommand->parseArgs(new StringArgs('vendor/package1')); + $args = self::$deleteCommand->parseArgs(new StringArgs('vendor/module1')); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('hasModule') - ->with('vendor/package1') + ->with('vendor/module1') ->willReturn(true); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('removeModule') - ->with('vendor/package1'); + ->with('vendor/module1'); $this->assertSame(0, $this->handler->handleDelete($args)); } /** * @expectedException \RuntimeException - * @expectedExceptionMessage The package "vendor/package1" is not installed. + * @expectedExceptionMessage The module "vendor/module1" is not installed. */ public function testDeleteModuleFailsIfNotFound() { - $args = self::$deleteCommand->parseArgs(new StringArgs('vendor/package1')); + $args = self::$deleteCommand->parseArgs(new StringArgs('vendor/module1')); - $this->packageManager->expects($this->once()) + $this->moduleManager->expects($this->once()) ->method('hasModule') - ->with('vendor/package1') + ->with('vendor/module1') ->willReturn(false); - $this->packageManager->expects($this->never()) + $this->moduleManager->expects($this->never()) ->method('removeModule') - ->with('vendor/package1'); + ->with('vendor/module1'); $this->handler->handleDelete($args); } @@ -545,13 +545,13 @@ public function testCleanModules() { $args = self::$cleanCommand->parseArgs(new StringArgs('')); - // The not-found package - $this->packageManager->expects($this->once()) + // The not-found module + $this->moduleManager->expects($this->once()) ->method('removeModule') - ->with('vendor/package3'); + ->with('vendor/module3'); $expected = <<<'EOF' -Removing vendor/package3 +Removing vendor/module3 EOF; diff --git a/tests/Handler/TypeCommandHandlerTest.php b/tests/Handler/TypeCommandHandlerTest.php index 57e63c9..32c2143 100644 --- a/tests/Handler/TypeCommandHandlerTest.php +++ b/tests/Handler/TypeCommandHandlerTest.php @@ -63,7 +63,7 @@ class TypeCommandHandlerTest extends AbstractCommandHandlerTest /** * @var ModuleList */ - private $packages; + private $modules; /** * @var TypeCommandHandler @@ -85,17 +85,17 @@ protected function setUp() parent::setUp(); $this->discoveryManager = $this->getMock('Puli\Manager\Api\Discovery\DiscoveryManager'); - $this->packages = new ModuleList(array( + $this->modules = new ModuleList(array( new RootModule(new RootModuleFile('vendor/root'), '/root'), - new Module(new ModuleFile('vendor/package1'), '/package1'), - new Module(new ModuleFile('vendor/package2'), '/package2'), + new Module(new ModuleFile('vendor/module1'), '/module1'), + new Module(new ModuleFile('vendor/module2'), '/module2'), )); - $this->handler = new TypeCommandHandler($this->discoveryManager, $this->packages); + $this->handler = new TypeCommandHandler($this->discoveryManager, $this->modules); $this->discoveryManager->expects($this->any()) ->method('findTypeDescriptors') ->willReturnCallback($this->returnFromMap(array( - array($this->packageAndState('vendor/root', BindingTypeState::ENABLED), array( + array($this->moduleAndState('vendor/root', BindingTypeState::ENABLED), array( new BindingTypeDescriptor( new BindingType('root/enabled1', array( new BindingParameter('req-param', BindingParameter::REQUIRED), @@ -109,20 +109,20 @@ protected function setUp() ), new BindingTypeDescriptor(new BindingType('root/enabled2'), 'Description of root/enabled2'), )), - array($this->packageAndState('vendor/root', BindingTypeState::DUPLICATE), array( + array($this->moduleAndState('vendor/root', BindingTypeState::DUPLICATE), array( new BindingTypeDescriptor(new BindingType('root/duplicate')), )), - array($this->packageAndState('vendor/package1', BindingTypeState::ENABLED), array( - new BindingTypeDescriptor(new BindingType('package1/enabled')), + array($this->moduleAndState('vendor/module1', BindingTypeState::ENABLED), array( + new BindingTypeDescriptor(new BindingType('module1/enabled')), )), - array($this->packageAndState('vendor/package1', BindingTypeState::DUPLICATE), array( - new BindingTypeDescriptor(new BindingType('package1/duplicate')), + array($this->moduleAndState('vendor/module1', BindingTypeState::DUPLICATE), array( + new BindingTypeDescriptor(new BindingType('module1/duplicate')), )), - array($this->packageAndState('vendor/package2', BindingTypeState::ENABLED), array( - new BindingTypeDescriptor(new BindingType('package2/enabled')), + array($this->moduleAndState('vendor/module2', BindingTypeState::ENABLED), array( + new BindingTypeDescriptor(new BindingType('module2/enabled')), )), - array($this->packageAndState('vendor/package2', BindingTypeState::DUPLICATE), array( - new BindingTypeDescriptor(new BindingType('package2/duplicate')), + array($this->moduleAndState('vendor/module2', BindingTypeState::DUPLICATE), array( + new BindingTypeDescriptor(new BindingType('module2/duplicate')), )), ))); } @@ -134,7 +134,7 @@ public function testListAllTypes() $expected = <<<'EOF' The following binding types are currently enabled: - Package: vendor/root + Module: vendor/root Type Description Parameters root/enabled1 Description of opt-param="default" @@ -142,32 +142,32 @@ public function testListAllTypes() root/enabled2 Description of root/enabled2 - Package: vendor/package1 + Module: vendor/module1 - Type Description Parameters - package1/enabled + Type Description Parameters + module1/enabled - Package: vendor/package2 + Module: vendor/module2 - Type Description Parameters - package2/enabled + Type Description Parameters + module2/enabled The following types have duplicate definitions and are disabled: - Package: vendor/root + Module: vendor/root Type Description Parameters root/duplicate - Package: vendor/package1 + Module: vendor/module1 - Type Description Parameters - package1/duplicate + Type Description Parameters + module1/duplicate - Package: vendor/package2 + Module: vendor/module2 - Type Description Parameters - package2/duplicate + Type Description Parameters + module2/duplicate Use "puli bind " to bind a resource to a type. @@ -178,7 +178,7 @@ public function testListAllTypes() $this->assertEmpty($this->io->fetchErrors()); } - public function testListRootPackageTypes() + public function testListRootModuleTypes() { $args = self::$listCommand->parseArgs(new StringArgs('--root')); @@ -204,20 +204,20 @@ public function testListRootPackageTypes() $this->assertEmpty($this->io->fetchErrors()); } - public function testListPackageTypes() + public function testListModuleTypes() { - $args = self::$listCommand->parseArgs(new StringArgs('--package vendor/package1')); + $args = self::$listCommand->parseArgs(new StringArgs('--module vendor/module1')); $expected = <<<'EOF' The following binding types are currently enabled: - Type Description Parameters - package1/enabled + Type Description Parameters + module1/enabled The following types have duplicate definitions and are disabled: - Type Description Parameters - package1/duplicate + Type Description Parameters + module1/duplicate Use "puli bind " to bind a resource to a type. @@ -228,14 +228,14 @@ public function testListPackageTypes() $this->assertEmpty($this->io->fetchErrors()); } - public function testListRootAndPackageTypes() + public function testListRootAndModuleTypes() { - $args = self::$listCommand->parseArgs(new StringArgs('--root --package vendor/package1')); + $args = self::$listCommand->parseArgs(new StringArgs('--root --module vendor/module1')); $expected = <<<'EOF' The following binding types are currently enabled: - Package: vendor/root + Module: vendor/root Type Description Parameters root/enabled1 Description of opt-param="default" @@ -243,22 +243,22 @@ public function testListRootAndPackageTypes() root/enabled2 Description of root/enabled2 - Package: vendor/package1 + Module: vendor/module1 - Type Description Parameters - package1/enabled + Type Description Parameters + module1/enabled The following types have duplicate definitions and are disabled: - Package: vendor/root + Module: vendor/root Type Description Parameters root/duplicate - Package: vendor/package1 + Module: vendor/module1 - Type Description Parameters - package1/duplicate + Type Description Parameters + module1/duplicate Use "puli bind " to bind a resource to a type. @@ -269,34 +269,34 @@ public function testListRootAndPackageTypes() $this->assertEmpty($this->io->fetchErrors()); } - public function testListMultiplePackageTypes() + public function testListMultipleModuleTypes() { - $args = self::$listCommand->parseArgs(new StringArgs('--package vendor/package1 --package vendor/package2')); + $args = self::$listCommand->parseArgs(new StringArgs('--module vendor/module1 --module vendor/module2')); $expected = <<<'EOF' The following binding types are currently enabled: - Package: vendor/package1 + Module: vendor/module1 - Type Description Parameters - package1/enabled + Type Description Parameters + module1/enabled - Package: vendor/package2 + Module: vendor/module2 - Type Description Parameters - package2/enabled + Type Description Parameters + module2/enabled The following types have duplicate definitions and are disabled: - Package: vendor/package1 + Module: vendor/module1 - Type Description Parameters - package1/duplicate + Type Description Parameters + module1/duplicate - Package: vendor/package2 + Module: vendor/module2 - Type Description Parameters - package2/duplicate + Type Description Parameters + module2/duplicate Use "puli bind " to bind a resource to a type. @@ -312,22 +312,22 @@ public function testListEnabledTypes() $args = self::$listCommand->parseArgs(new StringArgs('--enabled')); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root Type Description Parameters root/enabled1 Description of root/enabled1 opt-param="default" req-param root/enabled2 Description of root/enabled2 -Package: vendor/package1 +Module: vendor/module1 - Type Description Parameters - package1/enabled + Type Description Parameters + module1/enabled -Package: vendor/package2 +Module: vendor/module2 - Type Description Parameters - package2/enabled + Type Description Parameters + module2/enabled EOF; @@ -342,20 +342,20 @@ public function testListDuplicateTypes() $args = self::$listCommand->parseArgs(new StringArgs('--duplicate')); $expected = <<<'EOF' -Package: vendor/root +Module: vendor/root Type Description Parameters root/duplicate -Package: vendor/package1 +Module: vendor/module1 - Type Description Parameters - package1/duplicate + Type Description Parameters + module1/duplicate -Package: vendor/package2 +Module: vendor/module2 - Type Description Parameters - package2/duplicate + Type Description Parameters + module2/duplicate EOF; @@ -372,7 +372,7 @@ public function testListEnabledAndDuplicateTypes() $expected = <<<'EOF' The following binding types are currently enabled: - Package: vendor/root + Module: vendor/root Type Description Parameters root/enabled1 Description of opt-param="default" @@ -380,32 +380,32 @@ public function testListEnabledAndDuplicateTypes() root/enabled2 Description of root/enabled2 - Package: vendor/package1 + Module: vendor/module1 - Type Description Parameters - package1/enabled + Type Description Parameters + module1/enabled - Package: vendor/package2 + Module: vendor/module2 - Type Description Parameters - package2/enabled + Type Description Parameters + module2/enabled The following types have duplicate definitions and are disabled: - Package: vendor/root + Module: vendor/root Type Description Parameters root/duplicate - Package: vendor/package1 + Module: vendor/module1 - Type Description Parameters - package1/duplicate + Type Description Parameters + module1/duplicate - Package: vendor/package2 + Module: vendor/module2 - Type Description Parameters - package2/duplicate + Type Description Parameters + module2/duplicate Use "puli bind " to bind a resource to a type. @@ -433,13 +433,13 @@ public function testListEnabledTypesInRoot() $this->assertEmpty($this->io->fetchErrors()); } - public function testListEnabledTypesInPackage() + public function testListEnabledTypesInModule() { - $args = self::$listCommand->parseArgs(new StringArgs('--enabled --package vendor/package1')); + $args = self::$listCommand->parseArgs(new StringArgs('--enabled --module vendor/module1')); $expected = <<<'EOF' -Type Description Parameters -package1/enabled +Type Description Parameters +module1/enabled EOF; @@ -454,7 +454,7 @@ public function testListNoTypes() $this->discoveryManager->expects($this->any()) ->method('findTypeDescriptors') ->willReturn(array()); - $this->handler = new TypeCommandHandler($this->discoveryManager, $this->packages); + $this->handler = new TypeCommandHandler($this->discoveryManager, $this->modules); $args = self::$listCommand->parseArgs(new StringArgs('')); @@ -553,7 +553,7 @@ public function testUpdateTypeDescription() $args = self::$updateCommand->parseArgs(new StringArgs('my/type --description "New description"')); $typeDescriptor = new BindingTypeDescriptor(new BindingType('my/type'), 'Old description'); - $typeDescriptor->load($this->packages->getRootModule()); + $typeDescriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -578,7 +578,7 @@ public function testUpdateTypeOptionalParameterToRequired() null, array('param' => 'The description') ); - $typeDescriptor->load($this->packages->getRootModule()); + $typeDescriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -609,7 +609,7 @@ public function testUpdateTypeRequiredParameterToOptional() null, array('param' => 'The description') ); - $typeDescriptor->load($this->packages->getRootModule()); + $typeDescriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -640,7 +640,7 @@ public function testUpdateTypeChangeParameterDescription() null, array('param' => 'Old description') ); - $typeDescriptor->load($this->packages->getRootModule()); + $typeDescriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -670,7 +670,7 @@ public function testUpdateTypeRemoveParameter() new BindingParameter('param2', BindingParameter::OPTIONAL), )) ); - $typeDescriptor->load($this->packages->getRootModule()); + $typeDescriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -696,7 +696,7 @@ public function testUpdateTypeFailsIfNoChanges() $args = self::$updateCommand->parseArgs(new StringArgs('my/type')); $typeDescriptor = new BindingTypeDescriptor(new BindingType('my/type')); - $typeDescriptor->load($this->packages->getRootModule()); + $typeDescriptor->load($this->modules->getRootModule()); $this->discoveryManager->expects($this->once()) ->method('getRootTypeDescriptor') @@ -727,7 +727,7 @@ public function testDeleteType() /** * @expectedException \RuntimeException - * @expectedExceptionMessage The type "my/type" does not exist in the package "vendor/root". + * @expectedExceptionMessage The type "my/type" does not exist in the module "vendor/root". */ public function testDeleteTypeFailsIfNotFound() { @@ -744,7 +744,7 @@ public function testDeleteTypeFailsIfNotFound() $this->assertSame(0, $this->handler->handleDelete($args)); } - private function packageAndState($moduleName, $state) + private function moduleAndState($moduleName, $state) { return Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName))) ->andMethod('getState', Expr::same($state)); diff --git a/tests/Handler/UpgradeCommandHandlerTest.php b/tests/Handler/UpgradeCommandHandlerTest.php index a666c83..07d3272 100644 --- a/tests/Handler/UpgradeCommandHandlerTest.php +++ b/tests/Handler/UpgradeCommandHandlerTest.php @@ -13,9 +13,9 @@ use PHPUnit_Framework_MockObject_MockObject; use Puli\Cli\Handler\UpgradeCommandHandler; -use Puli\Manager\Api\Module\ModuleFile; use Puli\Manager\Api\Module\RootModuleFile; use Puli\Manager\Api\Module\RootModuleFileManager; +use Puli\Manager\Module\ModuleFileConverter; use Webmozart\Console\Api\Command\Command; use Webmozart\Console\Args\StringArgs; @@ -34,12 +34,12 @@ class UpgradeCommandHandlerTest extends AbstractCommandHandlerTest /** * @var PHPUnit_Framework_MockObject_MockObject|RootModuleFileManager */ - private $packageFileManager; + private $moduleFileManager; /** * @var RootModuleFile */ - private $packageFile; + private $moduleFile; /** * @var UpgradeCommandHandler @@ -57,22 +57,22 @@ protected function setUp() { parent::setUp(); - $this->packageFileManager = $this->getMock('Puli\Manager\Api\Module\RootModuleFileManager'); - $this->packageFile = new RootModuleFile(); - $this->packageFileManager->expects($this->any()) + $this->moduleFileManager = $this->getMock('Puli\Manager\Api\Module\RootModuleFileManager'); + $this->moduleFile = new RootModuleFile(); + $this->moduleFileManager->expects($this->any()) ->method('getModuleFile') - ->willReturn($this->packageFile); - $this->handler = new UpgradeCommandHandler($this->packageFileManager); + ->willReturn($this->moduleFile); + $this->handler = new UpgradeCommandHandler($this->moduleFileManager); } public function testUpgradeToDefaultVersion() { $args = self::$upgradeCommand->parseArgs(new StringArgs('')); - $defaultVersion = ModuleFile::DEFAULT_VERSION; + $defaultVersion = ModuleFileConverter::VERSION; - $this->packageFile->setVersion('0.5'); + $this->moduleFile->setVersion('0.5'); - $this->packageFileManager->expects($this->once()) + $this->moduleFileManager->expects($this->once()) ->method('migrate') ->with($defaultVersion); @@ -90,9 +90,9 @@ public function testUpgradeToExplicitVersion() { $args = self::$upgradeCommand->parseArgs(new StringArgs('0.8')); - $this->packageFile->setVersion('0.5'); + $this->moduleFile->setVersion('0.5'); - $this->packageFileManager->expects($this->once()) + $this->moduleFileManager->expects($this->once()) ->method('migrate') ->with('0.8'); @@ -110,9 +110,9 @@ public function testUpgradeDoesNothingIfAlreadyCorrectVersion() { $args = self::$upgradeCommand->parseArgs(new StringArgs('0.5')); - $this->packageFile->setVersion('0.5'); + $this->moduleFile->setVersion('0.5'); - $this->packageFileManager->expects($this->never()) + $this->moduleFileManager->expects($this->never()) ->method('migrate'); $expected = <<<'EOF' From 4f4118eef7098ae1b3b0bfb52edb55db09b1913c Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 10 Aug 2016 16:33:11 +0200 Subject: [PATCH 5/7] Minor --- src/PuliApplicationConfig.php | 1 - tests/Fixtures/root/puli.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PuliApplicationConfig.php b/src/PuliApplicationConfig.php index 3a42736..488c1d1 100644 --- a/src/PuliApplicationConfig.php +++ b/src/PuliApplicationConfig.php @@ -33,7 +33,6 @@ use Puli\Manager\Api\Container; use Puli\Manager\Api\Context\ProjectContext; use Puli\Manager\Api\Module\InstallInfo; -use Puli\Manager\Api\Module\ModuleFile; use Puli\Manager\Api\Server\Server; use Puli\Manager\Module\ModuleFileConverter; use Webmozart\Console\Api\Args\Format\Argument; diff --git a/tests/Fixtures/root/puli.json b/tests/Fixtures/root/puli.json index c309212..878418b 100644 --- a/tests/Fixtures/root/puli.json +++ b/tests/Fixtures/root/puli.json @@ -1,5 +1,5 @@ { - "version": "1.0", + "$schema": "http://puli.io/schema/2.0/manager/module#", "packages": { "puli/url-generator": { "install-path": "vendor/puli/url-generator" From 9755d4a9391298a055dcb34b76375a4ddb75e87b Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sat, 13 Aug 2016 20:15:33 +0200 Subject: [PATCH 6/7] Skip tests that are failing because of https://github.com/puli/issues/issues/198 --- tests/PuliBinTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/PuliBinTest.php b/tests/PuliBinTest.php index 10db7f1..d4665a9 100644 --- a/tests/PuliBinTest.php +++ b/tests/PuliBinTest.php @@ -176,7 +176,11 @@ private function runPuli($command) if (0 !== $status) { echo $output."\n"; - echo $process->getErrorOutput()."\n"; + echo $error = $process->getErrorOutput()."\n"; + + if (false !== strstr($error, 'The passed JSON did not match the schema:') && false !== strstr($error, 'The property packages is not defined')) { + $this->markTestSkipped('Do not skip this test when https://github.com/puli/issues/issues/198 is fixed'); + } } $this->assertSame(0, $status); From 09156ad966bc42544649f7869e3fbed7981172d6 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 15 Aug 2016 18:14:18 +0200 Subject: [PATCH 7/7] Removed skipped --- tests/PuliBinTest.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/PuliBinTest.php b/tests/PuliBinTest.php index d4665a9..10db7f1 100644 --- a/tests/PuliBinTest.php +++ b/tests/PuliBinTest.php @@ -176,11 +176,7 @@ private function runPuli($command) if (0 !== $status) { echo $output."\n"; - echo $error = $process->getErrorOutput()."\n"; - - if (false !== strstr($error, 'The passed JSON did not match the schema:') && false !== strstr($error, 'The property packages is not defined')) { - $this->markTestSkipped('Do not skip this test when https://github.com/puli/issues/issues/198 is fixed'); - } + echo $process->getErrorOutput()."\n"; } $this->assertSame(0, $status);