diff --git a/index.php b/index.php index c47a55e1e255057883a6b182b12657c8303fdb88..e74879ad90e8335282e79bf38c1430e371565f19 100644 --- a/index.php +++ b/index.php @@ -10,7 +10,7 @@ * $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; * $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); * \/** @var \Magento\Framework\App\Http $app *\/ - * $app = $bootstrap->createApplication('Magento\Framework\App\Http'); + * $app = $bootstrap->createApplication(\Magento\Framework\App\Http::class); * $bootstrap->run($app); * -------------------------------------------- * @@ -35,5 +35,5 @@ HTML; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); /** @var \Magento\Framework\App\Http $app */ -$app = $bootstrap->createApplication('Magento\Framework\App\Http'); +$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class); $bootstrap->run($app); diff --git a/pub/cron.php b/pub/cron.php index 32d64e07e0f5f5c45615103a0cb4e9bc3783eac7..ded37b7e0523cff6bf5f6dc97fad2a2edae55e47 100644 --- a/pub/cron.php +++ b/pub/cron.php @@ -29,7 +29,7 @@ try { $params[Store::CUSTOM_ENTRY_POINT_PARAM] = true; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\Framework\App\Cron $app */ - $app = $bootstrap->createApplication('Magento\Framework\App\Cron', ['parameters' => $opt]); + $app = $bootstrap->createApplication(\Magento\Framework\App\Cron::class, ['parameters' => $opt]); $bootstrap->run($app); } catch (\Exception $e) { echo $e; diff --git a/pub/errors/processorFactory.php b/pub/errors/processorFactory.php index a0944c4f1fc61aa10d03c6fce6b58b185ae669ac..f7f808d0c0a5ccbdcdf76721426063878ae8570c 100644 --- a/pub/errors/processorFactory.php +++ b/pub/errors/processorFactory.php @@ -22,7 +22,7 @@ class ProcessorFactory { $objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); $objectManager = $objectManagerFactory->create($_SERVER); - $response = $objectManager->create('Magento\Framework\App\Response\Http'); + $response = $objectManager->create(\Magento\Framework\App\Response\Http::class); return new Processor($response); } } diff --git a/pub/get.php b/pub/get.php index 760f922adb1403f82de4ecf643e375ab4ceacb97..4be6159bb463eb792f54f38f3ce9ad1b7f77ffd0 100644 --- a/pub/get.php +++ b/pub/get.php @@ -74,7 +74,7 @@ if (empty($mediaDirectory)) { $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\MediaStorage\App\Media $app */ $app = $bootstrap->createApplication( - 'Magento\MediaStorage\App\Media', + \Magento\MediaStorage\App\Media::class, [ 'mediaDirectory' => $mediaDirectory, 'configCacheFile' => $configCacheFile, diff --git a/pub/index.php b/pub/index.php index 9d4682cdf685e873020e9b1e96f6ed524364ce34..4f7735083241ffefdff28f3bfe8afa2d04cfef4e 100644 --- a/pub/index.php +++ b/pub/index.php @@ -33,5 +33,5 @@ $params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [ ]; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\Framework\App\Http $app */ -$app = $bootstrap->createApplication('Magento\Framework\App\Http'); +$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class); $bootstrap->run($app); diff --git a/pub/static.php b/pub/static.php index 5626be1563781f2a5347417c36f04e4e8bbaf83c..2476bfb4a0e28d475446fefb9229695fec483253 100644 --- a/pub/static.php +++ b/pub/static.php @@ -9,5 +9,5 @@ require realpath(__DIR__) . '/../app/bootstrap.php'; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); /** @var \Magento\Framework\App\StaticResource $app */ -$app = $bootstrap->createApplication('Magento\Framework\App\StaticResource'); +$app = $bootstrap->createApplication(\Magento\Framework\App\StaticResource::class); $bootstrap->run($app); diff --git a/setup/config/application.config.php b/setup/config/application.config.php index 8d3f88d044e2255c41ca26a63b7730012411c55a..6984d2504e3ff2995d7c5a3728d8569eaef89a35 100644 --- a/setup/config/application.config.php +++ b/setup/config/application.config.php @@ -18,10 +18,10 @@ return [ __DIR__ . '/autoload/{,*.}{global,local}.php', ], ], - 'listeners' => ['Magento\Setup\Mvc\Bootstrap\InitParamListener'], + 'listeners' => [\Magento\Setup\Mvc\Bootstrap\InitParamListener::class], 'service_manager' => [ 'factories' => [ - InitParamListener::BOOTSTRAP_PARAM => 'Magento\Setup\Mvc\Bootstrap\InitParamListener', + InitParamListener::BOOTSTRAP_PARAM => \Magento\Setup\Mvc\Bootstrap\InitParamListener::class, ], ], ]; diff --git a/setup/config/di.config.php b/setup/config/di.config.php index 9c73aae475358f63c853c9458a6cb67e6796d022..0a58bf202263995c8bb11f50676f48cd298edc63 100644 --- a/setup/config/di.config.php +++ b/setup/config/di.config.php @@ -7,49 +7,50 @@ return [ 'di' => [ 'allowed_controllers' => [ - 'Magento\Setup\Controller\Index', - 'Magento\Setup\Controller\LandingInstaller', - 'Magento\Setup\Controller\LandingUpdater', - 'Magento\Setup\Controller\CreateBackup', - 'Magento\Setup\Controller\CompleteBackup', - 'Magento\Setup\Controller\Navigation', - 'Magento\Setup\Controller\Home', - 'Magento\Setup\Controller\SelectVersion', - 'Magento\Setup\Controller\License', - 'Magento\Setup\Controller\ReadinessCheckInstaller', - 'Magento\Setup\Controller\ReadinessCheckUpdater', - 'Magento\Setup\Controller\Environment', - 'Magento\Setup\Controller\DependencyCheck', - 'Magento\Setup\Controller\DatabaseCheck', - 'Magento\Setup\Controller\AddDatabase', - 'Magento\Setup\Controller\WebConfiguration', - 'Magento\Setup\Controller\CustomizeYourStore', - 'Magento\Setup\Controller\CreateAdminAccount', - 'Magento\Setup\Controller\Install', - 'Magento\Setup\Controller\Success', - 'Magento\Setup\Controller\Modules', - 'Magento\Setup\Controller\ComponentGrid', - 'Magento\Setup\Controller\StartUpdater', - 'Magento\Setup\Controller\UpdaterSuccess', - 'Magento\Setup\Controller\BackupActionItems', - 'Magento\Setup\Controller\Maintenance', - 'Magento\Setup\Controller\OtherComponentsGrid', - 'Magento\Setup\Controller\DataOption', - 'Magento\Setup\Controller\Marketplace', - 'Magento\Setup\Controller\SystemConfig', - 'Magento\Setup\Controller\InstallExtensionGrid', - 'Magento\Setup\Controller\MarketplaceCredentials', - 'Magento\Setup\Controller\Session' + \Magento\Setup\Controller\Index::class, + \Magento\Setup\Controller\LandingInstaller::class, + \Magento\Setup\Controller\LandingUpdater::class, + \Magento\Setup\Controller\CreateBackup::class, + \Magento\Setup\Controller\CompleteBackup::class, + \Magento\Setup\Controller\Navigation::class, + \Magento\Setup\Controller\Home::class, + \Magento\Setup\Controller\SelectVersion::class, + \Magento\Setup\Controller\License::class, + \Magento\Setup\Controller\ReadinessCheckInstaller::class, + \Magento\Setup\Controller\ReadinessCheckUpdater::class, + \Magento\Setup\Controller\Environment::class, + \Magento\Setup\Controller\DependencyCheck::class, + \Magento\Setup\Controller\DatabaseCheck::class, + \Magento\Setup\Controller\AddDatabase::class, + \Magento\Setup\Controller\WebConfiguration::class, + \Magento\Setup\Controller\CustomizeYourStore::class, + \Magento\Setup\Controller\CreateAdminAccount::class, + \Magento\Setup\Controller\Install::class, + \Magento\Setup\Controller\Success::class, + \Magento\Setup\Controller\Modules::class, + \Magento\Setup\Controller\ComponentGrid::class, + \Magento\Setup\Controller\StartUpdater::class, + \Magento\Setup\Controller\UpdaterSuccess::class, + \Magento\Setup\Controller\BackupActionItems::class, + \Magento\Setup\Controller\Maintenance::class, + \Magento\Setup\Controller\OtherComponentsGrid::class, + \Magento\Setup\Controller\DataOption::class, + \Magento\Setup\Controller\Marketplace::class, + \Magento\Setup\Controller\SystemConfig::class, + \Magento\Setup\Controller\InstallExtensionGrid::class, + \Magento\Setup\Controller\MarketplaceCredentials::class, + \Magento\Setup\Controller\Session::class, ], 'instance' => [ 'preference' => [ - 'Zend\EventManager\EventManagerInterface' => 'EventManager', - 'Zend\ServiceManager\ServiceLocatorInterface' => 'ServiceManager', - 'Magento\Framework\DB\LoggerInterface' => 'Magento\Framework\DB\Logger\Quiet', - 'Magento\Framework\Locale\ConfigInterface' => 'Magento\Framework\Locale\Config', - 'Magento\Framework\Filesystem\DriverInterface' => 'Magento\Framework\Filesystem\Driver\File', - 'Magento\Framework\Component\ComponentRegistrarInterface' => - 'Magento\Framework\Component\ComponentRegistrar', + \Zend\EventManager\EventManagerInterface::class => 'EventManager', + \Zend\ServiceManager\ServiceLocatorInterface::class => 'ServiceManager', + \Magento\Framework\DB\LoggerInterface::class => \Magento\Framework\DB\Logger\Quiet::class, + \Magento\Framework\Locale\ConfigInterface::class => \Magento\Framework\Locale\Config::class, + \Magento\Framework\Filesystem\DriverInterface::class => + \Magento\Framework\Filesystem\Driver\File::class, + \Magento\Framework\Component\ComponentRegistrarInterface::class => + \Magento\Framework\Component\ComponentRegistrar::class, ], ], ], diff --git a/setup/config/router.config.php b/setup/config/router.config.php index 723cb300fc440c4a08e4fb0365b1aa3e4c7defac..c612d04772c08e548b311d496ec6abdc220fab08 100644 --- a/setup/config/router.config.php +++ b/setup/config/router.config.php @@ -13,7 +13,7 @@ return [ 'options' => [ 'route' => '/', 'defaults' => [ - 'controller' => 'Magento\Setup\Controller\Index', + 'controller' => \Magento\Setup\Controller\Index::class, 'action' => 'index', ], ], diff --git a/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php index 0c1a4ede0ebff40e3634af8f3cd1a9fc663cd5e4..a712c277af4f780906a39bbadc013eebb814f0cb 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php @@ -91,11 +91,11 @@ abstract class AbstractDependenciesCommand extends Command { try { /** @var \Magento\Framework\Component\ComponentRegistrar $componentRegistrar */ - $componentRegistrar = $this->objectManager->get('Magento\Framework\Component\ComponentRegistrar'); + $componentRegistrar = $this->objectManager->get(\Magento\Framework\Component\ComponentRegistrar::class); /** @var \Magento\Framework\Component\DirSearch $dirSearch */ - $dirSearch = $this->objectManager->get('Magento\Framework\Component\DirSearch'); + $dirSearch = $this->objectManager->get(\Magento\Framework\Component\DirSearch::class); /** @var \Magento\Framework\View\Design\Theme\ThemePackageList $themePackageList */ - $themePackageList = $this->objectManager->get('Magento\Framework\View\Design\Theme\ThemePackageList'); + $themePackageList = $this->objectManager->get(\Magento\Framework\View\Design\Theme\ThemePackageList::class); Files::setInstance(new Files($componentRegistrar, $dirSearch, $themePackageList)); $this->buildReport($input->getOption(self::INPUT_KEY_OUTPUT)); $output->writeln('<info>Report successfully processed.</info>'); diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php index 9a06568e1385fc185364aaf01cb59558e802dd2a..0bfdd6d7cfe102e485de8776818f1101a5298467 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php @@ -78,11 +78,11 @@ abstract class AbstractModuleCommand extends AbstractSetupCommand protected function cleanup(InputInterface $input, OutputInterface $output) { /** @var \Magento\Framework\App\Cache $cache */ - $cache = $this->objectManager->get('Magento\Framework\App\Cache'); + $cache = $this->objectManager->get(\Magento\Framework\App\Cache::class); $cache->clean(); $output->writeln('<info>Cache cleared successfully.</info>'); /** @var \Magento\Framework\App\State\CleanupFiles $cleanupFiles */ - $cleanupFiles = $this->objectManager->get('Magento\Framework\App\State\CleanupFiles'); + $cleanupFiles = $this->objectManager->get(\Magento\Framework\App\State\CleanupFiles::class); $cleanupFiles->clearCodeGeneratedClasses(); $output->writeln( "<info>Generated classes cleared successfully. Please run the 'setup:di:compile' command to " diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php index e207f114a69eb1c7cecf3388c02c9cdb9e6a04c5..b0ed5ddcd938371a4e17c84fd728eba386cb5127 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php @@ -61,7 +61,7 @@ abstract class AbstractModuleManageCommand extends AbstractModuleCommand $isEnable = $this->isEnable(); if ($input->getOption(self::INPUT_KEY_ALL)) { /** @var \Magento\Framework\Module\FullModuleList $fullModulesList */ - $fullModulesList = $this->objectManager->get('Magento\Framework\Module\FullModuleList'); + $fullModulesList = $this->objectManager->get(\Magento\Framework\Module\FullModuleList::class); $modules = $fullModulesList->getNames(); } else { $modules = $input->getArgument(self::INPUT_KEY_MODULES); @@ -165,7 +165,7 @@ abstract class AbstractModuleManageCommand extends AbstractModuleCommand /** * Get deployment config - * + * * @return DeploymentConfig * @deprecated */ diff --git a/setup/src/Magento/Setup/Console/Command/BackupCommand.php b/setup/src/Magento/Setup/Console/Command/BackupCommand.php index decb6c4a8cbf5cef9bec3c3bca9fa83c8ed2230e..63f4aeffce99dd8452e149f64b7f0c087a4a1f57 100644 --- a/setup/src/Magento/Setup/Console/Command/BackupCommand.php +++ b/setup/src/Magento/Setup/Console/Command/BackupCommand.php @@ -71,7 +71,7 @@ class BackupCommand extends AbstractSetupCommand ) { $this->objectManager = $objectManagerProvider->get(); $this->maintenanceMode = $maintenanceMode; - $this->backupRollbackFactory = $this->objectManager->get('Magento\Framework\Setup\BackupRollbackFactory'); + $this->backupRollbackFactory = $this->objectManager->get(\Magento\Framework\Setup\BackupRollbackFactory::class); $this->deploymentConfig = $deploymentConfig; parent::__construct(); } @@ -158,10 +158,10 @@ class BackupCommand extends AbstractSetupCommand { $areaCode = 'adminhtml'; /** @var \Magento\Framework\App\State $appState */ - $appState = $this->objectManager->get('Magento\Framework\App\State'); + $appState = $this->objectManager->get(\Magento\Framework\App\State::class); $appState->setAreaCode($areaCode); /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ - $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $configLoader = $this->objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class); $this->objectManager->configure($configLoader->load($areaCode)); } } diff --git a/setup/src/Magento/Setup/Console/Command/DbStatusCommand.php b/setup/src/Magento/Setup/Console/Command/DbStatusCommand.php index e9e0ac0f819c378a06e83c3651fbae4bfc58a27a..cb114d24e96ed2af61ac92cea22105357a7ee68a 100644 --- a/setup/src/Magento/Setup/Console/Command/DbStatusCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DbStatusCommand.php @@ -65,7 +65,7 @@ class DbStatusCommand extends AbstractSetupCommand } /** @var DbVersionInfo $dbVersionInfo */ $dbVersionInfo = $this->objectManagerProvider->get() - ->get('Magento\Framework\Module\DbVersionInfo'); + ->get(\Magento\Framework\Module\DbVersionInfo::class); $outdated = $dbVersionInfo->getDbVersionErrors(); if (!empty($outdated)) { $output->writeln("<info>The module code base doesn't match the DB schema and data.</info>"); diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index c4002f4043e1d2e7612d087cab64b887f6fbe6f2..06c603faceb9e3a507ed2393d1a3d2b31f384978 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -133,7 +133,7 @@ class DiCompileCommand extends Command $libraryPaths = $this->componentRegistrar->getPaths(ComponentRegistrar::LIBRARY); $generationPath = $this->directoryList->getPath(DirectoryList::GENERATION); - $this->objectManager->get('Magento\Framework\App\Cache')->clean(); + $this->objectManager->get(\Magento\Framework\App\Cache::class)->clean(); $compiledPathsList = [ 'application' => $modulePaths, 'library' => $libraryPaths, @@ -171,7 +171,7 @@ class DiCompileCommand extends Command /** @var ProgressBar $progressBar */ $progressBar = $this->objectManager->create( - 'Symfony\Component\Console\Helper\ProgressBar', + \Symfony\Component\Console\Helper\ProgressBar::class, [ 'output' => $output, 'max' => count($operations) @@ -225,39 +225,38 @@ class DiCompileCommand extends Command { $this->objectManager->configure( [ - 'preferences' => [ - 'Magento\Setup\Module\Di\Compiler\Config\WriterInterface' => - 'Magento\Setup\Module\Di\Compiler\Config\Writer\Filesystem', - ], - 'Magento\Setup\Module\Di\Compiler\Config\ModificationChain' => [ + 'preferences' => [\Magento\Setup\Module\Di\Compiler\Config\WriterInterface::class => + \Magento\Setup\Module\Di\Compiler\Config\Writer\Filesystem::class, + ], \Magento\Setup\Module\Di\Compiler\Config\ModificationChain::class => [ 'arguments' => [ 'modificationsList' => [ 'BackslashTrim' => - ['instance' => 'Magento\Setup\Module\Di\Compiler\Config\Chain\BackslashTrim'], + ['instance' => \Magento\Setup\Module\Di\Compiler\Config\Chain\BackslashTrim::class], 'PreferencesResolving' => - ['instance' => 'Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving'], + ['instance' => + \Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving::class], 'InterceptorSubstitution' => - ['instance' => 'Magento\Setup\Module\Di\Compiler\Config\Chain\InterceptorSubstitution'], + ['instance' => + \Magento\Setup\Module\Di\Compiler\Config\Chain\InterceptorSubstitution::class], 'InterceptionPreferencesResolving' => - ['instance' => 'Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving'], + ['instance' => + \Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving::class], 'ArgumentsSerialization' => - ['instance' => 'Magento\Setup\Module\Di\Compiler\Config\Chain\ArgumentsSerialization'], + ['instance' => + \Magento\Setup\Module\Di\Compiler\Config\Chain\ArgumentsSerialization::class], ] ] - ], - 'Magento\Setup\Module\Di\Code\Generator\PluginList' => [ + ], \Magento\Setup\Module\Di\Code\Generator\PluginList::class => [ 'arguments' => [ 'cache' => [ - 'instance' => 'Magento\Framework\App\Interception\Cache\CompiledConfig' + 'instance' => \Magento\Framework\App\Interception\Cache\CompiledConfig::class ] ] - ], - 'Magento\Setup\Module\Di\Code\Reader\ClassesScanner' => [ + ], \Magento\Setup\Module\Di\Code\Reader\ClassesScanner::class => [ 'arguments' => [ 'excludePatterns' => $this->excludedPathsList ] - ], - 'Magento\Setup\Module\Di\Compiler\Log\Writer\Console' => [ + ], \Magento\Setup\Module\Di\Compiler\Log\Writer\Console::class => [ 'arguments' => [ 'output' => $output, ] diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php new file mode 100644 index 0000000000000000000000000000000000000000..ac6a43189d7abe247be6ac87b91b60b3967314ed --- /dev/null +++ b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php @@ -0,0 +1,493 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Setup\Console\Command; + +use Magento\Framework\Filesystem\DriverInterface; +use Magento\Setup\Model\ObjectManagerProvider; +use Magento\Framework\App\ObjectManager; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputOption; +use Magento\Framework\Api\Code\Generator\Mapper; +use Magento\Framework\Api\Code\Generator\SearchResults; +use Magento\Framework\Autoload\AutoloaderRegistry; +use Magento\Framework\Component\ComponentRegistrar; +use Magento\Framework\Interception\Code\Generator\Interceptor; +use Magento\Framework\ObjectManager\Code\Generator\Converter; +use Magento\Framework\ObjectManager\Code\Generator\Factory; +use Magento\Framework\ObjectManager\Code\Generator\Proxy; +use Magento\Framework\ObjectManager\Code\Generator\Repository; +use Magento\Framework\ObjectManager\Code\Generator\Persistor; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator; +use Magento\Setup\Module\Di\Code\Scanner; +use Magento\Setup\Module\Di\Compiler\Log\Log; +use Magento\Setup\Module\Di\Compiler\Log\Writer; +use Magento\Setup\Module\Di\Definition\Compressor; +use Magento\Setup\Module\Di\Definition\Serializer\Igbinary; +use Magento\Setup\Module\Di\Definition\Serializer\Standard; +use \Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Code\Generator as CodeGenerator; + +/** + * Command to generate all non-existing proxies and factories, and pre-compile class definitions, + * inheritance information and plugin definitions + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class DiCompileMultiTenantCommand extends AbstractSetupCommand +{ + /**#@+ + * Names of input options + */ + const INPUT_KEY_SERIALIZER = 'serializer'; + const INPUT_KEY_EXTRA_CLASSES_FILE = 'extra-classes-file'; + const INPUT_KEY_GENERATION = 'generation'; + const INPUT_KEY_DI= 'di'; + const INPUT_KEY_EXCLUDE_PATTERN= 'exclude-pattern'; + /**#@- */ + + /**#@+ + * Possible values for serializer + */ + const SERIALIZER_VALUE_SERIALIZE = 'serialize'; + const SERIALIZER_VALUE_IGBINARY = 'igbinary'; + /**#@- */ + + /** Command name */ + const NAME = 'setup:di:compile-multi-tenant'; + + /** + * Object Manager + * + * @var ObjectManager + */ + private $objectManager; + + /** + * Filesystem Directory List + * + * @var DirectoryList + */ + private $directoryList; + + /** + * + * @var array + */ + private $entities; + + /** + * + * @var array + */ + private $files = []; + + /** + * + * @var CodeGenerator + */ + private $generator; + + /** + * + * @var Log + */ + private $log; + + /** + * @var ComponentRegistrar + */ + private $componentRegistrar; + + /** + * Constructor + * + * @param ObjectManagerProvider $objectManagerProvider + * @param DirectoryList $directoryList + * @param ComponentRegistrar $componentRegistrar + */ + public function __construct( + ObjectManagerProvider $objectManagerProvider, + DirectoryList $directoryList, + ComponentRegistrar $componentRegistrar + ) { + $this->objectManager = $objectManagerProvider->get(); + $this->directoryList = $directoryList; + $this->componentRegistrar = $componentRegistrar; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $options = [ + new InputOption( + self::INPUT_KEY_SERIALIZER, + null, + InputOption::VALUE_REQUIRED, + 'Serializer function that should be used (' . self::SERIALIZER_VALUE_SERIALIZE . '|' + . self::SERIALIZER_VALUE_IGBINARY . ') default: ' . self::SERIALIZER_VALUE_SERIALIZE + ), + new InputOption( + self::INPUT_KEY_EXTRA_CLASSES_FILE, + null, + InputOption::VALUE_REQUIRED, + 'Path to file with extra proxies and factories to generate' + ), + new InputOption( + self::INPUT_KEY_GENERATION, + null, + InputOption::VALUE_REQUIRED, + 'Absolute path to generated classes, <magento_root>/var/generation by default' + ), + new InputOption( + self::INPUT_KEY_DI, + null, + InputOption::VALUE_REQUIRED, + 'Absolute path to DI definitions directory, <magento_root>/var/di by default' + ), + new InputOption( + self::INPUT_KEY_EXCLUDE_PATTERN, + null, + InputOption::VALUE_REQUIRED, + 'Allows to exclude Paths from compilation (default is #[\\\\/]m1[\\\\/]#i)' + ), + ]; + $this->setName(self::NAME) + ->setDescription( + 'Generates all non-existing proxies and factories, and pre-compile class definitions, ' + . 'inheritance information and plugin definitions' + ) + ->setDefinition($options); + parent::configure(); + } + + /** + * Get module directories exclude patterns + * + * @return array + */ + private function getModuleExcludePatterns() + { + $modulesExcludePatterns = []; + foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $modulePath) { + $modulesExcludePatterns[] = "#^" . $modulePath . "/Test#"; + } + return $modulesExcludePatterns; + } + + /** + * Get library directories exclude patterns + * + * @return array + */ + private function getLibraryExcludePatterns() + { + $libraryExcludePatterns = []; + foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::LIBRARY) as $libraryPath) { + $libraryExcludePatterns[] = "#^" . $libraryPath . "/([\\w]+/)?Test#"; + } + return $libraryExcludePatterns; + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $errors = $this->validate($input); + if ($errors) { + $output->writeln($errors); + return; + } + + $generationDir = $input->getOption(self::INPUT_KEY_GENERATION) ? $input->getOption(self::INPUT_KEY_GENERATION) + : $this->directoryList->getPath(DirectoryList::GENERATION); + $modulesExcludePatterns = $this->getModuleExcludePatterns(); + $testExcludePatterns = [ + "#^" . $this->directoryList->getPath(DirectoryList::SETUP) . "/[\\w]+/[\\w]+/Test#", + "#^" . $this->directoryList->getRoot() . "/dev/tools/Magento/Tools/[\\w]+/Test#" + ]; + $librariesExcludePatterns = $this->getLibraryExcludePatterns(); + $testExcludePatterns = array_merge($testExcludePatterns, $modulesExcludePatterns, $librariesExcludePatterns); + $fileExcludePatterns = $input->getOption('exclude-pattern') ? + [$input->getOption(self::INPUT_KEY_EXCLUDE_PATTERN)] : ['#[\\\\/]M1[\\\\/]#i']; + $fileExcludePatterns = array_merge($fileExcludePatterns, $testExcludePatterns); + /** @var Writer\Console logWriter Writer model for success messages */ + $logWriter = new Writer\Console($output); + $this->log = new Log($logWriter, $logWriter); + AutoloaderRegistry::getAutoloader()->addPsr4('Magento\\', $generationDir . '/Magento/'); + // 1 Code generation + $this->generateCode($generationDir, $fileExcludePatterns, $input); + // 2. Compilation + $this->compileCode($generationDir, $fileExcludePatterns, $input); + //Reporter + $this->log->report(); + if (!$this->log->hasError()) { + $output->writeln( + '<info>On *nix systems, verify the Magento application has permissions to modify files ' + . 'created by the compiler in the "var" directory. For instance, if you run the Magento application ' + . 'using Apache, the owner of the files in the "var" directory should be the Apache user (example ' + . 'command: "chown -R www-data:www-data <MAGENTO_ROOT>/var" where MAGENTO_ROOT is the Magento ' + . 'root directory).</info>' + ); + } + } + + /** + * Generate Code + * + * @param string $generationDir + * @param array $fileExcludePatterns + * @param InputInterface $input + * @return void + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + public function generateCode($generationDir, $fileExcludePatterns, $input) + { + // 1.1 Code scan + $filePatterns = ['php' => '/.*\.php$/', 'di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/']; + $directoryScanner = new Scanner\DirectoryScanner(); + foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $codeScanDir) { + $this->files = array_merge_recursive( + $this->files, + $directoryScanner->scan($codeScanDir, $filePatterns, $fileExcludePatterns) + ); + } + $this->files['di'][] = $this->directoryList->getPath( + \Magento\Framework\App\Filesystem\DirectoryList::CONFIG + ) . '/di.xml'; + $this->files['additional'] = [$input->getOption(self::INPUT_KEY_EXTRA_CLASSES_FILE)]; + $repositoryScanner = new Scanner\RepositoryScanner(); + $repositories = $repositoryScanner->collectEntities($this->files['di']); + $scanner = new Scanner\CompositeScanner(); + $scanner->addChild(new Scanner\PhpScanner($this->log), 'php'); + $scanner->addChild(new Scanner\XmlScanner($this->log), 'di'); + $scanner->addChild(new Scanner\ArrayScanner(), 'additional'); + $this->entities = $scanner->collectEntities($this->files); + $interceptorScanner = new Scanner\XmlInterceptorScanner(); + $this->entities['interceptors'] = $interceptorScanner->collectEntities($this->files['di']); + // 1.2 Generation of Factory and Additional Classes + $generatorIo = $this->objectManager->create( + \Magento\Framework\Code\Generator\Io::class, + ['generationDirectory' => $generationDir] + ); + $this->generator = $this->objectManager->create( + \Magento\Framework\Code\Generator::class, + ['ioObject' => $generatorIo] + ); + /** Initialize object manager for code generation based on configs */ + $this->generator->setObjectManager($this->objectManager); + $generatorAutoloader = new \Magento\Framework\Code\Generator\Autoloader($this->generator); + spl_autoload_register([$generatorAutoloader, 'load']); + + foreach ($repositories as $entityName) { + switch ($this->generator->generateClass($entityName)) { + case CodeGenerator::GENERATION_SUCCESS: + $this->log->add(Log::GENERATION_SUCCESS, $entityName); + break; + case CodeGenerator::GENERATION_ERROR: + $this->log->add(Log::GENERATION_ERROR, $entityName); + break; + case CodeGenerator::GENERATION_SKIP: + default: + //no log + break; + } + } + foreach (['php', 'additional'] as $type) { + sort($this->entities[$type]); + foreach ($this->entities[$type] as $entityName) { + switch ($this->generator->generateClass($entityName)) { + case CodeGenerator::GENERATION_SUCCESS: + $this->log->add(Log::GENERATION_SUCCESS, $entityName); + break; + case CodeGenerator::GENERATION_ERROR: + $this->log->add(Log::GENERATION_ERROR, $entityName); + break; + case CodeGenerator::GENERATION_SKIP: + default: + //no log + break; + } + } + } + } + + /** + * Compile Code + * + * @param string $generationDir + * @param array $fileExcludePatterns + * @param InputInterface $input + * @return void + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + private function compileCode($generationDir, $fileExcludePatterns, $input) + { + $diDir = $input->getOption(self::INPUT_KEY_DI) ? $input->getOption(self::INPUT_KEY_DI) : + $this->directoryList->getPath(DirectoryList::DI); + $relationsFile = $diDir . '/relations.ser'; + $pluginDefFile = $diDir . '/plugins.ser'; + $compilationDirs = [ + $this->directoryList->getPath(DirectoryList::SETUP) . '/Magento/Setup/Module', + $this->directoryList->getRoot() . '/dev/tools/Magento/Tools', + ]; + $compilationDirs = array_merge( + $compilationDirs, + $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE), + $this->componentRegistrar->getPaths(ComponentRegistrar::LIBRARY) + ); + $serializer = $input->getOption(self::INPUT_KEY_SERIALIZER) == Igbinary::NAME ? new Igbinary() : new Standard(); + // 2.1 Code scan + $validator = new \Magento\Framework\Code\Validator(); + $validator->add(new \Magento\Framework\Code\Validator\ConstructorIntegrity()); + $validator->add(new \Magento\Framework\Code\Validator\ContextAggregation()); + $classesScanner = new \Magento\Setup\Module\Di\Code\Reader\ClassesScanner(); + $classesScanner->addExcludePatterns($fileExcludePatterns); + $directoryInstancesNamesList = new \Magento\Setup\Module\Di\Code\Reader\Decorator\Directory( + $this->log, + new \Magento\Framework\Code\Reader\ClassReader(), + $classesScanner, + $validator, + $generationDir + ); + foreach ($compilationDirs as $path) { + if (is_readable($path)) { + $directoryInstancesNamesList->getList($path); + } + } + $inheritanceScanner = new Scanner\InheritanceInterceptorScanner( + new \Magento\Framework\ObjectManager\InterceptableValidator() + ); + $this->entities['interceptors'] = $inheritanceScanner->collectEntities( + get_declared_classes(), + $this->entities['interceptors'] + ); + // 2.1.1 Generation of Proxy and Interceptor Classes + foreach (['interceptors', 'di'] as $type) { + foreach ($this->entities[$type] as $entityName) { + switch ($this->generator->generateClass($entityName)) { + case CodeGenerator::GENERATION_SUCCESS: + $this->log->add(Log::GENERATION_SUCCESS, $entityName); + break; + case CodeGenerator::GENERATION_ERROR: + $this->log->add(Log::GENERATION_ERROR, $entityName); + break; + case CodeGenerator::GENERATION_SKIP: + default: + //no log + break; + } + } + } + //2.1.2 Compile relations for Proxy/Interceptor classes + $directoryInstancesNamesList->getList($generationDir); + $relations = $directoryInstancesNamesList->getRelations(); + // 2.2 Compression + $relationsFileDir = dirname($relationsFile); + if (!file_exists($relationsFileDir)) { + mkdir($relationsFileDir, 0777, true); + } + $relations = array_filter($relations); + file_put_contents($relationsFile, $serializer->serialize($relations)); + // 3. Plugin Definition Compilation + $pluginScanner = new Scanner\CompositeScanner(); + $pluginScanner->addChild(new Scanner\PluginScanner(), 'di'); + $pluginDefinitions = []; + $pluginList = $pluginScanner->collectEntities($this->files); + $pluginDefinitionList = new \Magento\Framework\Interception\Definition\Runtime(); + foreach ($pluginList as $type => $entityList) { + foreach ($entityList as $entity) { + $pluginDefinitions[ltrim($entity, '\\')] = $pluginDefinitionList->getMethodList($entity); + } + } + $outputContent = $serializer->serialize($pluginDefinitions); + $pluginDefFileDir = dirname($pluginDefFile); + if (!file_exists($pluginDefFileDir)) { + mkdir($pluginDefFileDir, 0777, true); + } + file_put_contents($pluginDefFile, $outputContent); + } + + /** + * Check if all option values provided by the user are valid + * + * @param InputInterface $input + * @return string[] + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ + private function validate(InputInterface $input) + { + $errors = []; + $options = $input->getOptions(); + foreach ($options as $key => $value) { + if (!$value) { + continue; + } + switch ($key) { + case self::INPUT_KEY_SERIALIZER: + if (($value !== self::SERIALIZER_VALUE_SERIALIZE) && ($value !== self::SERIALIZER_VALUE_IGBINARY)) { + $errors[] = '<error>Invalid value for command option \'' . self::INPUT_KEY_SERIALIZER + . '\'. Possible values (' . self::SERIALIZER_VALUE_SERIALIZE . '|' + . self::SERIALIZER_VALUE_IGBINARY . ').</error>'; + } + break; + case self::INPUT_KEY_EXTRA_CLASSES_FILE: + if (!file_exists($value)) { + $errors[] = '<error>Path does not exist for the value of command option \'' + . self::INPUT_KEY_EXTRA_CLASSES_FILE . '\'.</error>'; + } + break; + case self::INPUT_KEY_GENERATION: + $errorMsg = $this->validateOutputPath($value, self::INPUT_KEY_GENERATION); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case self::INPUT_KEY_DI: + $errorMsg = $this->validateOutputPath($value, self::INPUT_KEY_DI); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case self::INPUT_KEY_EXCLUDE_PATTERN: + if (@preg_match($value, null) === false) { + $errors[] = '<error>Invalid pattern for command option \'' . self::INPUT_KEY_EXCLUDE_PATTERN + . '\'.</error>'; + } + break; + } + } + return $errors; + } + + /** + * Validate output path based on type + * + * @param string $value + * @param string $type + * @return string + */ + private function validateOutputPath($value, $type) + { + $errorMsg = ''; + if (!file_exists($value)) { + $errorMsg = '<error>Path does not exist for the value of command option \'' . $type . '\'.</error>'; + } + if (file_exists($value) && !is_writeable($value)) { + $errorMsg .= '<error>Non-writable directory is provided by the value of command option \'' + . $type . '\'.</error>'; + + } + return $errorMsg; + } +} diff --git a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php index 3e62ac0dba42105e79d632ea77cabf0803e66f2b..44d670f3a1abbfc1d859629d50fb1c58743faaee 100644 --- a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php @@ -82,10 +82,11 @@ class GenerateFixturesCommand extends Command } /** @var $config \Magento\Indexer\Model\Config */ - $config = $fixtureModel->getObjectManager()->get('Magento\Indexer\Model\Config'); + $config = $fixtureModel->getObjectManager()->get(\Magento\Indexer\Model\Config::class); $indexerListIds = $config->getIndexers(); /** @var $indexerRegistry \Magento\Framework\Indexer\IndexerRegistry */ - $indexerRegistry = $fixtureModel->getObjectManager()->create('Magento\Framework\Indexer\IndexerRegistry'); + $indexerRegistry = $fixtureModel->getObjectManager() + ->create(\Magento\Framework\Indexer\IndexerRegistry::class); $indexersState = []; foreach ($indexerListIds as $indexerId) { $indexer = $indexerRegistry->get($indexerId['indexer_id']); diff --git a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php index d48e5612fde9f79344daa60f73aad54a6d4a79d2..1549548f7355bd5fc1eb939aa60ab7a2d0141ac8 100644 --- a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php @@ -182,7 +182,7 @@ class InstallStoreConfigurationCommand extends AbstractSetupCommand if (strcmp($value, '{{base_url}}') == 0) { break; } - $url = $this->objectManager->get('Magento\Framework\Url\Validator'); + $url = $this->objectManager->get(\Magento\Framework\Url\Validator::class); if (!$url->isValid($value)) { $errorMsgs = $url->getMessages(); $errors[] = '<error>' . 'Command option \'' . StoreConfigurationDataMapper::KEY_BASE_URL @@ -191,7 +191,7 @@ class InstallStoreConfigurationCommand extends AbstractSetupCommand break; case StoreConfigurationDataMapper::KEY_LANGUAGE: /** @var Locale $lists */ - $lists = $this->objectManager->get('Magento\Framework\Validator\Locale'); + $lists = $this->objectManager->get(\Magento\Framework\Validator\Locale::class); $errorMsg = $this->validateCodes($lists, $value, StoreConfigurationDataMapper::KEY_LANGUAGE); if ($errorMsg !== '') { $errors[] = $errorMsg; @@ -199,7 +199,7 @@ class InstallStoreConfigurationCommand extends AbstractSetupCommand break; case StoreConfigurationDataMapper::KEY_TIMEZONE: /** @var Timezone $lists */ - $lists = $this->objectManager->get('Magento\Framework\Validator\Timezone'); + $lists = $this->objectManager->get(\Magento\Framework\Validator\Timezone::class); $errorMsg = $this->validateCodes($lists, $value, StoreConfigurationDataMapper::KEY_TIMEZONE); if ($errorMsg !== '') { $errors[] = $errorMsg; @@ -207,7 +207,7 @@ class InstallStoreConfigurationCommand extends AbstractSetupCommand break; case StoreConfigurationDataMapper::KEY_CURRENCY: /** @var Currency $lists */ - $lists = $this->objectManager->get('Magento\Framework\Validator\Currency'); + $lists = $this->objectManager->get(\Magento\Framework\Validator\Currency::class); $errorMsg = $this->validateCodes($lists, $value, StoreConfigurationDataMapper::KEY_CURRENCY); if ($errorMsg !== '') { $errors[] = $errorMsg; @@ -228,7 +228,7 @@ class InstallStoreConfigurationCommand extends AbstractSetupCommand case StoreConfigurationDataMapper::KEY_BASE_URL_SECURE: try { /** @var Validator $url */ - $url = $this->objectManager->get('Magento\Framework\Url\Validator'); + $url = $this->objectManager->get(\Magento\Framework\Url\Validator::class); $errorMsgs = ''; if (!$url->isValid($value)) { $errorMsgs = $url->getMessages(); diff --git a/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php b/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php index 08d057c70d6440e7ec0db2af43d1f5ee9f3f752e..a81ace272e68d4461563f9a359dd6740b3491801 100644 --- a/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php @@ -47,7 +47,7 @@ class ModuleStatusCommand extends AbstractSetupCommand */ protected function execute(InputInterface $input, OutputInterface $output) { - $moduleList = $this->objectManagerProvider->get()->create('Magento\Framework\Module\ModuleList'); + $moduleList = $this->objectManagerProvider->get()->create(\Magento\Framework\Module\ModuleList::class); $output->writeln('<info>List of enabled modules:</info>'); $enabledModules = $moduleList->getNames(); if (count($enabledModules) === 0) { @@ -57,7 +57,7 @@ class ModuleStatusCommand extends AbstractSetupCommand } $output->writeln(''); - $fullModuleList = $this->objectManagerProvider->get()->create('Magento\Framework\Module\FullModuleList'); + $fullModuleList = $this->objectManagerProvider->get()->create(\Magento\Framework\Module\FullModuleList::class); $output->writeln("<info>List of disabled modules:</info>"); $disabledModules = array_diff($fullModuleList->getNames(), $enabledModules); if (count($disabledModules) === 0) { diff --git a/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php b/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php index 7b1bcd19fe40f9aa0ac0c1898a52563534e591dc..f723ccaa2f86e7be5470ab06542e101b211a01d7 100644 --- a/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php @@ -135,10 +135,10 @@ class ModuleUninstallCommand extends AbstractModuleCommand $this->deploymentConfig = $deploymentConfig; $this->maintenanceMode = $maintenanceMode; $this->fullModuleList = $fullModuleList; - $this->packageInfo = $this->objectManager->get('Magento\Framework\Module\PackageInfoFactory')->create(); + $this->packageInfo = $this->objectManager->get(\Magento\Framework\Module\PackageInfoFactory::class)->create(); $this->collector = $collector; - $this->dependencyChecker = $this->objectManager->get('Magento\Framework\Module\DependencyChecker'); - $this->backupRollbackFactory = $this->objectManager->get('Magento\Framework\Setup\BackupRollbackFactory'); + $this->dependencyChecker = $this->objectManager->get(\Magento\Framework\Module\DependencyChecker::class); + $this->backupRollbackFactory = $this->objectManager->get(\Magento\Framework\Setup\BackupRollbackFactory::class); $this->moduleUninstaller = $moduleUninstaller; $this->moduleRegistryUninstaller = $moduleRegistryUninstaller; } @@ -303,8 +303,6 @@ class ModuleUninstallCommand extends AbstractModuleCommand $this->moduleUninstaller->uninstallData($output, $modules); } - - /** * Validate list of modules against installed composer packages and return error messages * @@ -370,10 +368,10 @@ class ModuleUninstallCommand extends AbstractModuleCommand { $areaCode = 'adminhtml'; /** @var \Magento\Framework\App\State $appState */ - $appState = $this->objectManager->get('Magento\Framework\App\State'); + $appState = $this->objectManager->get(\Magento\Framework\App\State::class); $appState->setAreaCode($areaCode); /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ - $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $configLoader = $this->objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class); $this->objectManager->configure($configLoader->load($areaCode)); } } diff --git a/setup/src/Magento/Setup/Console/Command/RollbackCommand.php b/setup/src/Magento/Setup/Console/Command/RollbackCommand.php index a31d805de59539d5ee02de74927d7ac708589168..f68decfaaf57fa9bec7edaf112e37c09a61a8f32 100644 --- a/setup/src/Magento/Setup/Console/Command/RollbackCommand.php +++ b/setup/src/Magento/Setup/Console/Command/RollbackCommand.php @@ -68,7 +68,7 @@ class RollbackCommand extends AbstractSetupCommand ) { $this->objectManager = $objectManagerProvider->get(); $this->maintenanceMode = $maintenanceMode; - $this->backupRollbackFactory = $this->objectManager->get('Magento\Framework\Setup\BackupRollbackFactory'); + $this->backupRollbackFactory = $this->objectManager->get(\Magento\Framework\Setup\BackupRollbackFactory::class); $this->deploymentConfig = $deploymentConfig; parent::__construct(); } @@ -177,10 +177,10 @@ class RollbackCommand extends AbstractSetupCommand { $areaCode = 'adminhtml'; /** @var \Magento\Framework\App\State $appState */ - $appState = $this->objectManager->get('Magento\Framework\App\State'); + $appState = $this->objectManager->get(\Magento\Framework\App\State::class); $appState->setAreaCode($areaCode); /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ - $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $configLoader = $this->objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class); $this->objectManager->configure($configLoader->load($areaCode)); } } diff --git a/setup/src/Magento/Setup/Console/CommandList.php b/setup/src/Magento/Setup/Console/CommandList.php index c416ca04f25ac845c5c59fe5458f4d57d5abbfbc..4bb5ac0181a794b575b420499908d1cb3871b383 100644 --- a/setup/src/Magento/Setup/Console/CommandList.php +++ b/setup/src/Magento/Setup/Console/CommandList.php @@ -10,6 +10,8 @@ use Zend\ServiceManager\ServiceManager; /** * Class CommandList contains predefined list of commands for Setup + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CommandList { @@ -38,38 +40,38 @@ class CommandList protected function getCommandsClasses() { return [ - 'Magento\Setup\Console\Command\AdminUserCreateCommand', - 'Magento\Setup\Console\Command\BackupCommand', - 'Magento\Setup\Console\Command\ConfigSetCommand', - 'Magento\Setup\Console\Command\CronRunCommand', - 'Magento\Setup\Console\Command\DbDataUpgradeCommand', - 'Magento\Setup\Console\Command\DbSchemaUpgradeCommand', - 'Magento\Setup\Console\Command\DbStatusCommand', - 'Magento\Setup\Console\Command\DependenciesShowFrameworkCommand', - 'Magento\Setup\Console\Command\DependenciesShowModulesCircularCommand', - 'Magento\Setup\Console\Command\DependenciesShowModulesCommand', - 'Magento\Setup\Console\Command\DiCompileCommand', - 'Magento\Setup\Console\Command\GenerateFixturesCommand', - 'Magento\Setup\Console\Command\I18nCollectPhrasesCommand', - 'Magento\Setup\Console\Command\I18nPackCommand', - 'Magento\Setup\Console\Command\InfoAdminUriCommand', - 'Magento\Setup\Console\Command\InfoBackupsListCommand', - 'Magento\Setup\Console\Command\InfoCurrencyListCommand', - 'Magento\Setup\Console\Command\InfoLanguageListCommand', - 'Magento\Setup\Console\Command\InfoTimezoneListCommand', - 'Magento\Setup\Console\Command\InstallCommand', - 'Magento\Setup\Console\Command\InstallStoreConfigurationCommand', - 'Magento\Setup\Console\Command\ModuleEnableCommand', - 'Magento\Setup\Console\Command\ModuleDisableCommand', - 'Magento\Setup\Console\Command\ModuleStatusCommand', - 'Magento\Setup\Console\Command\ModuleUninstallCommand', - 'Magento\Setup\Console\Command\MaintenanceAllowIpsCommand', - 'Magento\Setup\Console\Command\MaintenanceDisableCommand', - 'Magento\Setup\Console\Command\MaintenanceEnableCommand', - 'Magento\Setup\Console\Command\MaintenanceStatusCommand', - 'Magento\Setup\Console\Command\RollbackCommand', - 'Magento\Setup\Console\Command\UpgradeCommand', - 'Magento\Setup\Console\Command\UninstallCommand', + \Magento\Setup\Console\Command\AdminUserCreateCommand::class, + \Magento\Setup\Console\Command\BackupCommand::class, + \Magento\Setup\Console\Command\ConfigSetCommand::class, + \Magento\Setup\Console\Command\CronRunCommand::class, + \Magento\Setup\Console\Command\DbDataUpgradeCommand::class, + \Magento\Setup\Console\Command\DbSchemaUpgradeCommand::class, + \Magento\Setup\Console\Command\DbStatusCommand::class, + \Magento\Setup\Console\Command\DependenciesShowFrameworkCommand::class, + \Magento\Setup\Console\Command\DependenciesShowModulesCircularCommand::class, + \Magento\Setup\Console\Command\DependenciesShowModulesCommand::class, + \Magento\Setup\Console\Command\DiCompileCommand::class, + \Magento\Setup\Console\Command\GenerateFixturesCommand::class, + \Magento\Setup\Console\Command\I18nCollectPhrasesCommand::class, + \Magento\Setup\Console\Command\I18nPackCommand::class, + \Magento\Setup\Console\Command\InfoAdminUriCommand::class, + \Magento\Setup\Console\Command\InfoBackupsListCommand::class, + \Magento\Setup\Console\Command\InfoCurrencyListCommand::class, + \Magento\Setup\Console\Command\InfoLanguageListCommand::class, + \Magento\Setup\Console\Command\InfoTimezoneListCommand::class, + \Magento\Setup\Console\Command\InstallCommand::class, + \Magento\Setup\Console\Command\InstallStoreConfigurationCommand::class, + \Magento\Setup\Console\Command\ModuleEnableCommand::class, + \Magento\Setup\Console\Command\ModuleDisableCommand::class, + \Magento\Setup\Console\Command\ModuleStatusCommand::class, + \Magento\Setup\Console\Command\ModuleUninstallCommand::class, + \Magento\Setup\Console\Command\MaintenanceAllowIpsCommand::class, + \Magento\Setup\Console\Command\MaintenanceDisableCommand::class, + \Magento\Setup\Console\Command\MaintenanceEnableCommand::class, + \Magento\Setup\Console\Command\MaintenanceStatusCommand::class, + \Magento\Setup\Console\Command\RollbackCommand::class, + \Magento\Setup\Console\Command\UpgradeCommand::class, + \Magento\Setup\Console\Command\UninstallCommand::class, ]; } diff --git a/setup/src/Magento/Setup/Controller/BackupActionItems.php b/setup/src/Magento/Setup/Controller/BackupActionItems.php index b5cf25bae675fc9715156c148ba490a42e1f6d5e..0b8d239104102e23f1351971c481a1d1e50de5a5 100644 --- a/setup/src/Magento/Setup/Controller/BackupActionItems.php +++ b/setup/src/Magento/Setup/Controller/BackupActionItems.php @@ -52,7 +52,10 @@ class BackupActionItems extends AbstractActionController \Magento\Framework\Backup\Filesystem $fileSystem ) { $objectManager = $objectManagerProvider->get(); - $this->backupHandler = $objectManager->create('Magento\Framework\Setup\BackupRollback', ['log' => $logger]); + $this->backupHandler = $objectManager->create( + \Magento\Framework\Setup\BackupRollback::class, + ['log' => $logger] + ); $this->directoryList = $directoryList; $this->fileSystem = $fileSystem; } diff --git a/setup/src/Magento/Setup/Controller/ComponentGrid.php b/setup/src/Magento/Setup/Controller/ComponentGrid.php index 2d7e11bb8b2fc9f89ae763586aed092c2468ef5f..885ed556ff7ba71148af1691152e8ea6dc61928e 100644 --- a/setup/src/Magento/Setup/Controller/ComponentGrid.php +++ b/setup/src/Magento/Setup/Controller/ComponentGrid.php @@ -69,9 +69,9 @@ class ComponentGrid extends \Zend\Mvc\Controller\AbstractActionController ) { $this->composerInformation = $composerInformation; $objectManager = $objectManagerProvider->get(); - $this->enabledModuleList = $objectManager->get('Magento\Framework\Module\ModuleList'); - $this->fullModuleList = $objectManager->get('Magento\Framework\Module\FullModuleList'); - $this->packageInfo = $objectManager->get('Magento\Framework\Module\PackageInfoFactory')->create(); + $this->enabledModuleList = $objectManager->get(\Magento\Framework\Module\ModuleList::class); + $this->fullModuleList = $objectManager->get(\Magento\Framework\Module\FullModuleList::class); + $this->packageInfo = $objectManager->get(\Magento\Framework\Module\PackageInfoFactory::class)->create(); $this->marketplaceManager = $marketplaceManager; $this->updatePackagesCache = $updatePackagesCache; $this->timezone = $tzProvider->get(); diff --git a/setup/src/Magento/Setup/Controller/CustomizeYourStore.php b/setup/src/Magento/Setup/Controller/CustomizeYourStore.php index 8d999964bd248c20de29391763a1da077f35cae4..c02e1515ad005269e07aba8bc643804a4deb7930 100644 --- a/setup/src/Magento/Setup/Controller/CustomizeYourStore.php +++ b/setup/src/Magento/Setup/Controller/CustomizeYourStore.php @@ -50,7 +50,7 @@ class CustomizeYourStore extends AbstractActionController $sampleDataDeployed = $this->moduleList->has('Magento_SampleData'); if ($sampleDataDeployed) { /** @var \Magento\Framework\Setup\SampleData\State $sampleData */ - $sampleData = $this->objectManagerProvider->get()->get('Magento\Framework\Setup\SampleData\State'); + $sampleData = $this->objectManagerProvider->get()->get(\Magento\Framework\Setup\SampleData\State::class); $isSampleDataInstalled = $sampleData->isInstalled(); $isSampleDataErrorInstallation = $sampleData->hasError(); } else { diff --git a/setup/src/Magento/Setup/Controller/Modules.php b/setup/src/Magento/Setup/Controller/Modules.php index 9c88e90a49f07644093acfd2466503f494b3e5cb..aba4306aca49eb31a7e119cadf12651e663dc632 100644 --- a/setup/src/Magento/Setup/Controller/Modules.php +++ b/setup/src/Magento/Setup/Controller/Modules.php @@ -85,7 +85,7 @@ class Modules extends AbstractActionController */ private function checkGraph(array $toBeEnabledModules, $prettyFormat = false) { - $status = $this->objectManager->create('Magento\Framework\Module\Status'); + $status = $this->objectManager->create(\Magento\Framework\Module\Status::class); // checking enabling constraints $constraints = $status->checkConstraints(true, $toBeEnabledModules, [], $prettyFormat); @@ -105,7 +105,7 @@ class Modules extends AbstractActionController public function validateAction() { $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY); - $status = $this->objectManager->create('Magento\Framework\Module\Status'); + $status = $this->objectManager->create(\Magento\Framework\Module\Status::class); $constraints = $status->checkConstraints( $params['status'], diff --git a/setup/src/Magento/Setup/Controller/Session.php b/setup/src/Magento/Setup/Controller/Session.php index 5003e422e7b648bdb9b7862768328b0498632dda..371365d11b62fbf157e1f3a76f3a679352cd2845 100644 --- a/setup/src/Magento/Setup/Controller/Session.php +++ b/setup/src/Magento/Setup/Controller/Session.php @@ -54,20 +54,20 @@ class Session extends AbstractActionController public function prolongAction() { try { - if ($this->serviceManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { + if ($this->serviceManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) { $objectManager = $this->objectManagerProvider->get(); /** @var \Magento\Framework\App\State $adminAppState */ - $adminAppState = $objectManager->get('Magento\Framework\App\State'); + $adminAppState = $objectManager->get(\Magento\Framework\App\State::class); $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); - $sessionConfig = $objectManager->get('Magento\Backend\Model\Session\AdminConfig'); + $sessionConfig = $objectManager->get(\Magento\Backend\Model\Session\AdminConfig::class); /** @var \Magento\Backend\Model\Url $backendUrl */ - $backendUrl = $objectManager->get('Magento\Backend\Model\Url'); + $backendUrl = $objectManager->get(\Magento\Backend\Model\Url::class); $urlPath = parse_url($backendUrl->getBaseUrl(), PHP_URL_PATH); $cookiePath = $urlPath . 'setup'; $sessionConfig->setCookiePath($cookiePath); /* @var \Magento\Backend\Model\Auth\Session $session */ $session = $objectManager->create( - 'Magento\Backend\Model\Auth\Session', + \Magento\Backend\Model\Auth\Session::class, [ 'sessionConfig' => $sessionConfig, 'appState' => $adminAppState diff --git a/setup/src/Magento/Setup/Controller/Success.php b/setup/src/Magento/Setup/Controller/Success.php index f3eab45eeefed165ae8b3f233282389f0c4203af..336380f1d8764f772f99458fb87c931649b4f2d7 100644 --- a/setup/src/Magento/Setup/Controller/Success.php +++ b/setup/src/Magento/Setup/Controller/Success.php @@ -39,7 +39,7 @@ class Success extends AbstractActionController { if ($this->moduleList->has('Magento_SampleData')) { /** @var \Magento\Framework\Setup\SampleData\State $sampleData */ - $sampleData = $this->objectManagerProvider->get()->get('Magento\Framework\Setup\SampleData\State'); + $sampleData = $this->objectManagerProvider->get()->get(\Magento\Framework\Setup\SampleData\State::class); $isSampleDataErrorInstallation = $sampleData->hasError(); } else { $isSampleDataErrorInstallation = false; diff --git a/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php index aa21ef70b1caeca42210c4f37abb87a3cb5f92f7..5e6a36d2f1d0329321ccaf7ea8edba10e0ed6abb 100755 --- a/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php @@ -50,11 +50,11 @@ class CartPriceRulesFixture extends Fixture ); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Category::class); /** @var $model \Magento\SalesRule\Model\RuleFactory */ - $modelFactory = $this->fixtureModel->getObjectManager()->get('Magento\SalesRule\Model\RuleFactory'); + $modelFactory = $this->fixtureModel->getObjectManager()->get(\Magento\SalesRule\Model\RuleFactory::class); //Get all websites $categoriesArray = []; @@ -97,25 +97,25 @@ class CartPriceRulesFixture extends Fixture return [ 'conditions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', ], '1--1' => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'total_qty', 'operator' => '>=', 'value' => $this->cartPriceRulesProductsFloor + $ruleId, ], '1--2' => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Found', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Found::class, 'value' => '1', 'aggregator' => 'all', 'new_child' => '', ], '1--2--1' => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'attribute' => 'category_ids', 'operator' => '==', 'value' => $categoriesArray[$ruleId % count($categoriesArray)][0], @@ -123,7 +123,7 @@ class CartPriceRulesFixture extends Fixture ], 'actions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', @@ -228,7 +228,7 @@ class CartPriceRulesFixture extends Fixture if ($ruleId < ($this->cartPriceRulesCount - 200)) { // Category $firstCondition = [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'attribute' => 'category_ids', 'operator' => '==', 'value' => $categoriesArray[($ruleId / 4 ) % count($categoriesArray)][0], @@ -237,7 +237,7 @@ class CartPriceRulesFixture extends Fixture $subtotal = [0, 5, 10, 15]; // Subtotal $secondCondition = [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'base_subtotal', 'operator' => '>=', 'value' => $subtotal[$ruleId % 4], @@ -246,13 +246,13 @@ class CartPriceRulesFixture extends Fixture return [ 'conditions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', ], '1--1'=> [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Found', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Found::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', @@ -262,7 +262,7 @@ class CartPriceRulesFixture extends Fixture ], 'actions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', @@ -280,7 +280,7 @@ class CartPriceRulesFixture extends Fixture 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming']; $firstCondition = [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'region', 'operator' => '==', 'value' => $regions[($ruleId / 4) % 50], @@ -289,7 +289,7 @@ class CartPriceRulesFixture extends Fixture $subtotals = [0, 5, 10, 15]; // Subtotal $secondCondition = [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'base_subtotal', 'operator' => '>=', 'value' => $subtotals[$ruleId % 4], @@ -297,7 +297,7 @@ class CartPriceRulesFixture extends Fixture return [ 'conditions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', @@ -307,7 +307,7 @@ class CartPriceRulesFixture extends Fixture ], 'actions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', diff --git a/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php b/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php index 46cfbe5ae0a6e5a1e621305b8a7a97f6cceed147..2296d5e5ec34f024f0b161485a96d0e80886ce43 100644 --- a/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php @@ -29,14 +29,15 @@ class CatalogPriceRulesFixture extends Fixture $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Category::class); /** @var $model \Magento\CatalogRule\Model\Rule*/ - $model = $this->fixtureModel->getObjectManager()->get('Magento\CatalogRule\Model\Rule'); + $model = $this->fixtureModel->getObjectManager()->get(\Magento\CatalogRule\Model\Rule::class); /** @var \Magento\Framework\EntityManager\MetadataPool $metadataPool */ - $metadataPool = $this->fixtureModel->getObjectManager()->get('Magento\Framework\EntityManager\MetadataPool'); - $metadata = $metadataPool->getMetadata('Magento\CatalogRule\Api\Data\RuleInterface'); + $metadataPool = $this->fixtureModel->getObjectManager() + ->get(\Magento\Framework\EntityManager\MetadataPool::class); + $metadata = $metadataPool->getMetadata(\Magento\CatalogRule\Api\Data\RuleInterface::class); //Get all websites $categoriesArray = []; @@ -85,13 +86,13 @@ class CatalogPriceRulesFixture extends Fixture 'rule' => [ 'conditions' => [ 1 => [ - 'type' => 'Magento\\CatalogRule\\Model\\Rule\\Condition\\Combine', + 'type' => \Magento\CatalogRule\Model\Rule\Condition\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', ], '1--1' => [ - 'type' => 'Magento\\CatalogRule\\Model\\Rule\\Condition\\Product', + 'type' => \Magento\CatalogRule\Model\Rule\Condition\Product::class, 'attribute' => 'category_ids', 'operator' => '==', 'value' => $categoriesArray[$i % count($categoriesArray)][0], diff --git a/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php b/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php index 01f550c58e3b5aade331631e9f943cafaf6c8139..16d7fde9378807bf1fc8029c0030d72d5a32568e 100644 --- a/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php @@ -29,9 +29,9 @@ class CategoriesFixture extends Fixture $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->fixtureModel->getObjectManager()->create('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->create(\Magento\Catalog\Model\Category::class); $storeGroups = $storeManager->getGroups(); $i = 0; diff --git a/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php index 3efcf395b0716b221177389081de96fc26cbc442..bc8362890b6381b4d0b541a386f5600064d57cc2 100644 --- a/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php @@ -30,7 +30,7 @@ class ConfigsApplyFixture extends Fixture foreach ($configs['config'] as $config) { $backendModel = isset($config['backend_model']) ? - $config['backend_model'] : 'Magento\Framework\App\Config\Value'; + $config['backend_model'] : \Magento\Framework\App\Config\Value::class; /** * @var \Magento\Framework\App\Config\ValueInterface $configData */ @@ -41,7 +41,7 @@ class ConfigsApplyFixture extends Fixture ->setValue($config['value']) ->save(); } - $this->fixtureModel->getObjectManager()->get('Magento\Framework\App\CacheInterface') + $this->fixtureModel->getObjectManager()->get(\Magento\Framework\App\CacheInterface::class) ->clean([\Magento\Framework\App\Config::CACHE_TAG]); } diff --git a/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php b/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php index 0cdc3bd9a202e451c456a323c998a330457d438d..09704f3274e65abfaa0f0b72e27004e767a45646 100644 --- a/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php @@ -581,9 +581,9 @@ class ConfigurableProductsFixture extends Fixture $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Category::class); $result = []; //Get all websites @@ -638,7 +638,7 @@ class ConfigurableProductsFixture extends Fixture /** @var \Magento\ImportExport\Model\Import $import */ $import = $this->fixtureModel->getObjectManager()->create( - 'Magento\ImportExport\Model\Import', + \Magento\ImportExport\Model\Import::class, [ 'data' => [ 'entity' => 'catalog_product', diff --git a/setup/src/Magento/Setup/Fixtures/CustomersFixture.php b/setup/src/Magento/Setup/Fixtures/CustomersFixture.php index fab712f336803d59ab89d3c2fdb9b25582e445f5..ca29b4cf704474425d3456d1a4711c6b92a19e56 100644 --- a/setup/src/Magento/Setup/Fixtures/CustomersFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CustomersFixture.php @@ -30,7 +30,7 @@ class CustomersFixture extends Fixture $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); /** @var $defaultStoreView \Magento\Store\Model\Store */ $defaultStoreView = $storeManager->getDefaultStoreView(); $defaultStoreViewId = $defaultStoreView->getStoreId(); @@ -93,7 +93,7 @@ class CustomersFixture extends Fixture $generator = new Generator($pattern, $customersNumber); /** @var \Magento\ImportExport\Model\Import $import */ $import = $this->fixtureModel->getObjectManager()->create( - 'Magento\ImportExport\Model\Import', + \Magento\ImportExport\Model\Import::class, [ 'data' => [ 'entity' => 'customer_composite', diff --git a/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php b/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php index 4799840afd86b3357098098affb28310970724b4..cff0548c2d104f59bcd64977236c3ee22ab5c2ec 100644 --- a/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php +++ b/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php @@ -30,9 +30,10 @@ class EavVariationsFixture extends Fixture $this->fixtureModel->resetObjectManager(); /* @var $model \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ - $model = $this->fixtureModel->getObjectManager()->create('Magento\Catalog\Model\ResourceModel\Eav\Attribute'); + $model = $this->fixtureModel->getObjectManager() + ->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); $stores = $storeManager->getStores(); $storeViewsCount = count($stores); @@ -89,7 +90,7 @@ class EavVariationsFixture extends Fixture * See MAGETWO-16492 */ $model->addData($data); - $attributeSet = $this->fixtureModel->getObjectManager()->get('Magento\Eav\Model\Entity\Attribute\Set'); + $attributeSet = $this->fixtureModel->getObjectManager()->get(\Magento\Eav\Model\Entity\Attribute\Set::class); $attributeSet->load(self::ATTRIBUTE_SET_ID); $model->setAttributeSetId(self::ATTRIBUTE_SET_ID) ->setAttributeGroupId($attributeSet->getDefaultGroupId(4)) @@ -99,7 +100,7 @@ class EavVariationsFixture extends Fixture $model->save(); /* @var $cache \Magento\Framework\App\CacheInterface */ - $cache = $this->fixtureModel->getObjectManager()->get('Magento\Framework\App\CacheInterface'); + $cache = $this->fixtureModel->getObjectManager()->get(\Magento\Framework\App\CacheInterface::class); $cacheKey = \Magento\Eav\Model\Config::ATTRIBUTES_CACHE_ID . \Magento\Catalog\Model\Product::ENTITY; $cache->remove($cacheKey); diff --git a/setup/src/Magento/Setup/Fixtures/FixtureModel.php b/setup/src/Magento/Setup/Fixtures/FixtureModel.php index 0bbb4167854d124a3393414276b63623319c7faa..118b29cb4306bb6e05580eea3bc0da207a72835d 100644 --- a/setup/src/Magento/Setup/Fixtures/FixtureModel.php +++ b/setup/src/Magento/Setup/Fixtures/FixtureModel.php @@ -14,6 +14,9 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; use Magento\Framework\Xml\Parser; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class FixtureModel { /** @@ -155,7 +158,7 @@ class FixtureModel $this->initArguments ); $this->objectManager = $objectManagerFactory->create($this->initArguments); - $this->objectManager->get('Magento\Framework\App\State')->setAreaCode(self::AREA_CODE); + $this->objectManager->get(\Magento\Framework\App\State::class)->setAreaCode(self::AREA_CODE); } return $this->objectManager; } @@ -170,10 +173,11 @@ class FixtureModel $this->getObjectManager() ->configure( $this->getObjectManager() - ->get('Magento\Framework\ObjectManager\ConfigLoaderInterface') + ->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class) ->load(self::AREA_CODE) ); - $this->getObjectManager()->get('Magento\Framework\Config\ScopeInterface')->setCurrentScope(self::AREA_CODE); + $this->getObjectManager()->get(\Magento\Framework\Config\ScopeInterface::class) + ->setCurrentScope(self::AREA_CODE); return $this; } diff --git a/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php b/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php index 471ed28e38dc643e20b93204754eb40c06a72743..9a80889e9c23268540dbae792576d67f888246e0 100644 --- a/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php +++ b/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php @@ -29,7 +29,7 @@ class IndexersStatesApplyFixture extends Fixture foreach ($indexers["indexer"] as $indexer) { $this->fixtureModel->indexersStates[$indexer['id']] = ($indexer['set_scheduled'] == "true"); } - $this->fixtureModel->getObjectManager()->get('Magento\Framework\App\CacheInterface') + $this->fixtureModel->getObjectManager()->get(\Magento\Framework\App\CacheInterface::class) ->clean([\Magento\Framework\App\Config::CACHE_TAG]); } diff --git a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php index 5e8b20da54430fa061a1713dd11e31666eb026dd..8210e4c941e015833916aed86cfd845d97a66bdb 100644 --- a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php +++ b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php @@ -10,6 +10,8 @@ use Magento\Framework\App\ResourceConnection; /** * Class OrdersFixture + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OrdersFixture extends Fixture { @@ -34,66 +36,66 @@ class OrdersFixture extends Fixture $quoteTableName = $this->getTableName( 'quote', - 'Magento\Quote\Model\ResourceModel\Quote' + \Magento\Quote\Model\ResourceModel\Quote::class ); $quoteAddressTableName = $this->getTableName( 'quote_address', - 'Magento\Quote\Model\ResourceModel\Quote\Address' + \Magento\Quote\Model\ResourceModel\Quote\Address::class ); $quoteItemTableName = $this->getTableName( 'quote_item', - 'Magento\Quote\Model\ResourceModel\Quote\Item' + \Magento\Quote\Model\ResourceModel\Quote\Item::class ); $quoteItemOptionTableName = $this->getTableName( 'quote_item_option', - 'Magento\Quote\Model\ResourceModel\Quote\Item\Option' + \Magento\Quote\Model\ResourceModel\Quote\Item\Option::class ); $quotePaymentTableName = $this->getTableName( 'quote_payment', - 'Magento\Quote\Model\ResourceModel\Quote\Payment' + \Magento\Quote\Model\ResourceModel\Quote\Payment::class ); $quoteAddressRateTableName = $this->getTableName( 'quote_shipping_rate', - 'Magento\Quote\Model\ResourceModel\Quote\Address\Rate' + \Magento\Quote\Model\ResourceModel\Quote\Address\Rate::class ); $reportEventTableName = $this->getTableName( 'report_event', - 'Magento\Reports\Model\ResourceModel\Event' + \Magento\Reports\Model\ResourceModel\Event::class ); $salesOrderTableName = $this->getTableName( 'sales_order', - 'Magento\Sales\Model\ResourceModel\Order' + \Magento\Sales\Model\ResourceModel\Order::class ); $salesOrderAddressTableName = $this->getTableName( 'sales_order_address', - 'Magento\Sales\Model\ResourceModel\Order' + \Magento\Sales\Model\ResourceModel\Order::class ); $salesOrderGridTableName = $this->getTableName( 'sales_order_grid', - 'Magento\Sales\Model\ResourceModel\Order\Grid' + \Magento\Sales\Model\ResourceModel\Order\Grid::class ); $salesOrderItemTableName = $this->getTableName( 'sales_order_item', - 'Magento\Sales\Model\ResourceModel\Order\Item' + \Magento\Sales\Model\ResourceModel\Order\Item::class ); $salesOrderPaymentTableName = $this->getTableName( 'sales_order_payment', - 'Magento\Sales\Model\ResourceModel\Order\Payment' + \Magento\Sales\Model\ResourceModel\Order\Payment::class ); $salesOrderStatusHistoryTableName = $this->getTableName( 'sales_order_status_history', - 'Magento\Sales\Model\ResourceModel\Order\Status\History' + \Magento\Sales\Model\ResourceModel\Order\Status\History::class ); $eavEntityStoreTableName = $this->getTableName( 'eav_entity_store', - '\Magento\Eav\Model\ResourceModel\Entity\Store' + \Magento\Eav\Model\ResourceModel\Entity\Store::class ); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Category::class); /** @var $product \Magento\Catalog\Model\Product */ - $product = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Product'); + $product = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Product::class); $result = []; $stores = $storeManager->getStores(); @@ -125,11 +127,12 @@ class OrdersFixture extends Fixture //Not use root categories if (trim($resultsCategoryName) != '') { /** @var $productCategory \Magento\Catalog\Model\Category */ - $productCategory = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); + $productCategory = $this->fixtureModel->getObjectManager() + ->get(\Magento\Catalog\Model\Category::class); /** @var $simpleProductCollection \Magento\Catalog\Model\ResourceModel\Product\Collection */ $simpleProductCollection = $this->fixtureModel->getObjectManager()->create( - 'Magento\Catalog\Model\ResourceModel\Product\Collection' + \Magento\Catalog\Model\ResourceModel\Product\Collection::class ); $simpleProductCollection->addStoreFilter($storeId); @@ -316,7 +319,7 @@ class OrdersFixture extends Fixture public function getConnection() { return $this->fixtureModel->getObjectManager()->get( - 'Magento\Framework\App\ResourceConnection' + \Magento\Framework\App\ResourceConnection::class )->getConnection(); } } diff --git a/setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php b/setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php index 39d20b67095d73352ff5931b153d0c745b9fdcbd..6de4eaf91529fb3bc12cffe4d78aba238bc2fc05 100644 --- a/setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php +++ b/setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php @@ -30,9 +30,9 @@ class SimpleProductsFixture extends Fixture $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get(\Magento\Catalog\Model\Category::class); $result = []; //Get all websites @@ -83,7 +83,7 @@ class SimpleProductsFixture extends Fixture ); /** @var \Magento\ImportExport\Model\Import $import */ $import = $this->fixtureModel->getObjectManager()->create( - 'Magento\ImportExport\Model\Import', + \Magento\ImportExport\Model\Import::class, [ 'data' => [ 'entity' => 'catalog_product', diff --git a/setup/src/Magento/Setup/Fixtures/StoresFixture.php b/setup/src/Magento/Setup/Fixtures/StoresFixture.php index 162482d75c1549c3b02776bdf3e69a3c7359506c..dcd7dd5b6f50cef5df6ad75e5fd4caef44e7e0d9 100644 --- a/setup/src/Magento/Setup/Fixtures/StoresFixture.php +++ b/setup/src/Magento/Setup/Fixtures/StoresFixture.php @@ -31,7 +31,7 @@ class StoresFixture extends Fixture $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create(\Magento\Store\Model\StoreManager::class); /** @var $category \Magento\Catalog\Model\Category */ /** @var $defaultWebsite \Magento\Store\Model\Website */ @@ -75,7 +75,7 @@ class StoresFixture extends Fixture //Create $storeGroupsCount websites $websiteNumber = 0; for ($i = 0; $i < $storeGroupsCount; $i++) { - $category = $this->fixtureModel->getObjectManager()->create('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->create(\Magento\Catalog\Model\Category::class); $websiteId = $websitesId[$websiteNumber]; $groupId = null; $categoryPath = '1'; diff --git a/setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php b/setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php index ae6ec34133c80867a8926c9e914fa1c692f74409..e024b47bc568aeeed06b60d92efc81e87faf7468 100644 --- a/setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php @@ -29,11 +29,11 @@ class TaxRatesFixture extends Fixture /** Clean predefined tax rates to maintain consistency */ /** @var $collection Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection */ $collection = $this->fixtureModel->getObjectManager() - ->get('Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection'); + ->get(\Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection::class); /** @var $model Magento\Tax\Model\Calculation\Rate */ $model = $this->fixtureModel->getObjectManager() - ->get('Magento\Tax\Model\Calculation\Rate'); + ->get(\Magento\Tax\Model\Calculation\Rate::class); foreach ($collection->getAllIds() as $id) { $model->setId($id); @@ -51,7 +51,7 @@ class TaxRatesFixture extends Fixture 'size' => filesize($filename), ]; $importHandler = $this->fixtureModel->getObjectManager() - ->create('Magento\TaxImportExport\Model\Rate\CsvImportHandler'); + ->create(\Magento\TaxImportExport\Model\Rate\CsvImportHandler::class); $importHandler->importFromCsvFile($file); } diff --git a/setup/src/Magento/Setup/Model/AdminAccountFactory.php b/setup/src/Magento/Setup/Model/AdminAccountFactory.php index bbc48f7c932323b9e856609edda76f99ecb40c58..36f997e980dee995b3095cd8f44485b1ba633bc7 100644 --- a/setup/src/Magento/Setup/Model/AdminAccountFactory.php +++ b/setup/src/Magento/Setup/Model/AdminAccountFactory.php @@ -33,7 +33,7 @@ class AdminAccountFactory { return new AdminAccount( $setup, - $this->serviceLocator->get('Magento\Framework\Encryption\Encryptor'), + $this->serviceLocator->get(\Magento\Framework\Encryption\Encryptor::class), $data ); } diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php b/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php index da6029ce5bb049a34849f9a4e4888b54d5c8ae40..524888c6c35718311ead9008ed95eb4d143bd906 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php @@ -96,7 +96,7 @@ class ConfigOptionsListCollector } // check Setup - $setupOptionsClassName = 'Magento\Setup\Model\ConfigOptionsList'; + $setupOptionsClassName = \Magento\Setup\Model\ConfigOptionsList::class; if (class_exists($setupOptionsClassName)) { $setupOptionsClass = $this->serviceLocator->get($setupOptionsClassName); if ($setupOptionsClass instanceof ConfigOptionsListInterface) { diff --git a/setup/src/Magento/Setup/Model/Cron/AbstractJob.php b/setup/src/Magento/Setup/Model/Cron/AbstractJob.php index a687e06156235633baa29e756bed2e933bd64bf5..fdfb57757b901c5b636b03b3667727cf59d51db2 100644 --- a/setup/src/Magento/Setup/Model/Cron/AbstractJob.php +++ b/setup/src/Magento/Setup/Model/Cron/AbstractJob.php @@ -54,7 +54,6 @@ abstract class AbstractJob */ protected $objectManager; - /** * Constructor * @@ -77,8 +76,8 @@ abstract class AbstractJob $this->params = $params; $this->objectManager = $objectManagerProvider->get(); - $this->cleanupFiles = $this->objectManager->get('Magento\Framework\App\State\CleanupFiles'); - $this->cache = $this->objectManager->get('Magento\Framework\App\Cache'); + $this->cleanupFiles = $this->objectManager->get(\Magento\Framework\App\State\CleanupFiles::class); + $this->cache = $this->objectManager->get(\Magento\Framework\App\Cache::class); } /** diff --git a/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php b/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php index 2151cbb84232294ee3d37e5c8ba99002ee788019..3ce4511c1ed94303759ed8f3a09fd29811c8741f 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php +++ b/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php @@ -81,10 +81,10 @@ class JobDbRollback extends AbstractJob { $areaCode = 'adminhtml'; /** @var \Magento\Framework\App\State $appState */ - $appState = $this->objectManager->get('Magento\Framework\App\State'); + $appState = $this->objectManager->get(\Magento\Framework\App\State::class); $appState->setAreaCode($areaCode); /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ - $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $configLoader = $this->objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class); $this->objectManager->configure($configLoader->load($areaCode)); } } diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php index 10d1d4f346c260bbde740319377f502b53db0475..14bb75197fc4b6cdc979f2576b56dee79c20b9a9 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php +++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php @@ -9,6 +9,8 @@ use Zend\ServiceManager\ServiceLocatorInterface; /** * Factory class to create jobs + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class JobFactory { @@ -47,20 +49,20 @@ class JobFactory */ public function create($name, array $params = []) { - $cronStatus = $this->serviceLocator->get('Magento\Setup\Model\Cron\Status'); + $cronStatus = $this->serviceLocator->get(\Magento\Setup\Model\Cron\Status::class); $statusStream = fopen($cronStatus->getStatusFilePath(), 'a+'); $logStream = fopen($cronStatus->getLogFilePath(), 'a+'); $multipleStreamOutput = new MultipleStreamOutput([$statusStream, $logStream]); - $objectManagerProvider = $this->serviceLocator->get('Magento\Setup\Model\ObjectManagerProvider'); + $objectManagerProvider = $this->serviceLocator->get(\Magento\Setup\Model\ObjectManagerProvider::class); /** @var \Magento\Framework\ObjectManagerInterface $objectManager */ $objectManager = $objectManagerProvider->get(); switch ($name) { case self::JOB_UPGRADE: return new JobUpgrade( - $this->serviceLocator->get('Magento\Setup\Console\Command\UpgradeCommand'), + $this->serviceLocator->get(\Magento\Setup\Console\Command\UpgradeCommand::class), $objectManagerProvider, $multipleStreamOutput, - $this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'), + $this->serviceLocator->get(\Magento\Setup\Model\Cron\Queue::class), $cronStatus, $name, $params @@ -68,7 +70,7 @@ class JobFactory break; case self::JOB_DB_ROLLBACK: return new JobDbRollback( - $objectManager->get('Magento\Framework\Setup\BackupRollbackFactory'), + $objectManager->get(\Magento\Framework\Setup\BackupRollbackFactory::class), $multipleStreamOutput, $cronStatus, $objectManagerProvider, @@ -87,30 +89,30 @@ class JobFactory break; case self::JOB_COMPONENT_UNINSTALL: $moduleUninstall = new Helper\ModuleUninstall( - $this->serviceLocator->get('Magento\Setup\Model\ModuleUninstaller'), - $this->serviceLocator->get('Magento\Setup\Model\ModuleRegistryUninstaller'), - $objectManager->get('Magento\Framework\Module\PackageInfoFactory') + $this->serviceLocator->get(\Magento\Setup\Model\ModuleUninstaller::class), + $this->serviceLocator->get(\Magento\Setup\Model\ModuleRegistryUninstaller::class), + $objectManager->get(\Magento\Framework\Module\PackageInfoFactory::class) ); $themeUninstall = new Helper\ThemeUninstall( - $objectManager->get('Magento\Theme\Model\Theme\ThemeUninstaller'), - $objectManager->get('Magento\Theme\Model\Theme\ThemePackageInfo') + $objectManager->get(\Magento\Theme\Model\Theme\ThemeUninstaller::class), + $objectManager->get(\Magento\Theme\Model\Theme\ThemePackageInfo::class) ); return new JobComponentUninstall( - $objectManager->get('Magento\Framework\Composer\ComposerInformation'), + $objectManager->get(\Magento\Framework\Composer\ComposerInformation::class), $moduleUninstall, $themeUninstall, $objectManagerProvider, $multipleStreamOutput, - $this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'), + $this->serviceLocator->get(\Magento\Setup\Model\Cron\Queue::class), $cronStatus, - $this->serviceLocator->get('Magento\Setup\Model\Updater'), + $this->serviceLocator->get(\Magento\Setup\Model\Updater::class), $name, $params ); break; case self::JOB_MODULE_ENABLE: return new JobModule( - $this->serviceLocator->get('Magento\Setup\Console\Command\ModuleEnableCommand'), + $this->serviceLocator->get(\Magento\Setup\Console\Command\ModuleEnableCommand::class), $objectManagerProvider, $multipleStreamOutput, $cronStatus, @@ -120,7 +122,7 @@ class JobFactory break; case self::JOB_MODULE_DISABLE: return new JobModule( - $this->serviceLocator->get('Magento\Setup\Console\Command\ModuleDisableCommand'), + $this->serviceLocator->get(\Magento\Setup\Console\Command\ModuleDisableCommand::class), $objectManagerProvider, $multipleStreamOutput, $cronStatus, diff --git a/setup/src/Magento/Setup/Model/Cron/JobStaticRegenerate.php b/setup/src/Magento/Setup/Model/Cron/JobStaticRegenerate.php index 01cb1dcc2e27f8e4db8647295646b02b944bc053..f592b151cf2878be0e5d29fcaff72707e7d7d7fb 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobStaticRegenerate.php +++ b/setup/src/Magento/Setup/Model/Cron/JobStaticRegenerate.php @@ -53,8 +53,8 @@ class JobStaticRegenerate extends AbstractJob $params = [] ) { $this->objectManager = $objectManagerProvider->get(); - $this->cleanupFiles = $this->objectManager->get('Magento\Framework\App\State\CleanupFiles'); - $this->cache = $this->objectManager->get('Magento\Framework\App\Cache'); + $this->cleanupFiles = $this->objectManager->get(\Magento\Framework\App\State\CleanupFiles::class); + $this->cache = $this->objectManager->get(\Magento\Framework\App\Cache::class); $this->output = $output; $this->status = $status; @@ -135,7 +135,7 @@ class JobStaticRegenerate extends AbstractJob */ public function getFilesystem() { - return $this->objectManager->create('Magento\Deploy\Model\Filesystem'); + return $this->objectManager->create(\Magento\Deploy\Model\Filesystem::class); } /** @@ -146,7 +146,7 @@ class JobStaticRegenerate extends AbstractJob public function getModeObject() { return $this->objectManager->create( - 'Magento\Deploy\Model\Mode', + \Magento\Deploy\Model\Mode::class, [ 'input' => new ArrayInput([]), 'output' => $this->output, diff --git a/setup/src/Magento/Setup/Model/DateTime/DateTimeProvider.php b/setup/src/Magento/Setup/Model/DateTime/DateTimeProvider.php index 073b6ee027bea71d8b6754d21550d9b7b26a93fc..72679d0c4a5a77d3b3d84f25a2456d5d99f56ab2 100644 --- a/setup/src/Magento/Setup/Model/DateTime/DateTimeProvider.php +++ b/setup/src/Magento/Setup/Model/DateTime/DateTimeProvider.php @@ -54,7 +54,7 @@ class DateTimeProvider { if (!$this->dateTime) { $this->dateTime = $this->objectManagerProvider->get()->create( - 'Magento\Framework\Stdlib\DateTime\DateTime', + \Magento\Framework\Stdlib\DateTime\DateTime::class, ['localeDate' => $this->tzProvider->get()] ); } diff --git a/setup/src/Magento/Setup/Model/DateTime/TimezoneProvider.php b/setup/src/Magento/Setup/Model/DateTime/TimezoneProvider.php index dfff802bc793cc0a08fe280344bd9eed3fa8e84b..2b1c3ac86443113bc33dc8b4e311080d3d5da1e1 100644 --- a/setup/src/Magento/Setup/Model/DateTime/TimezoneProvider.php +++ b/setup/src/Magento/Setup/Model/DateTime/TimezoneProvider.php @@ -46,7 +46,7 @@ class TimezoneProvider { if (!$this->timezone) { $this->timezone = $this->objectManagerProvider->get()->create( - 'Magento\Framework\Stdlib\DateTime\Timezone', + \Magento\Framework\Stdlib\DateTime\Timezone::class, ['scopeType' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT] ); } diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index 39d80861878d014983fb1d4f1f2de32bb9789ee2..74a08e2795c5d3afafabf8c2e5ed9471cec57247 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -68,10 +68,10 @@ class Installer /**#@+ * Instance types for schema and data handler */ - const SCHEMA_INSTALL = 'Magento\Framework\Setup\InstallSchemaInterface'; - const SCHEMA_UPGRADE = 'Magento\Framework\Setup\UpgradeSchemaInterface'; - const DATA_INSTALL = 'Magento\Framework\Setup\InstallDataInterface'; - const DATA_UPGRADE = 'Magento\Framework\Setup\UpgradeDataInterface'; + const SCHEMA_INSTALL = \Magento\Framework\Setup\InstallSchemaInterface::class; + const SCHEMA_UPGRADE = \Magento\Framework\Setup\UpgradeSchemaInterface::class; + const DATA_INSTALL = \Magento\Framework\Setup\InstallDataInterface::class; + const DATA_UPGRADE = \Magento\Framework\Setup\UpgradeDataInterface::class; /**#@- */ const INFO_MESSAGE = 'message'; @@ -898,7 +898,7 @@ class Installer { $userConfig = new StoreConfigurationDataMapper(); /** @var \Magento\Framework\App\State $appState */ - $appState = $this->objectManagerProvider->get()->get('Magento\Framework\App\State'); + $appState = $this->objectManagerProvider->get()->get(\Magento\Framework\App\State::class); $appState->setAreaCode('setup'); $configData = $userConfig->getConfigData($data); if (count($configData) === 0) { @@ -906,7 +906,7 @@ class Installer } /** @var \Magento\Config\Model\Config\Factory $configFactory */ - $configFactory = $this->objectManagerProvider->get()->create('Magento\Config\Model\Config\Factory'); + $configFactory = $this->objectManagerProvider->get()->create(\Magento\Config\Model\Config\Factory::class); foreach ($configData as $key => $val) { $configModel = $configFactory->create(); $configModel->setDataByPath($key, $val); @@ -1048,7 +1048,7 @@ class Installer private function enableCaches() { /** @var \Magento\Framework\App\Cache\Manager $cacheManager */ - $cacheManager = $this->objectManagerProvider->get()->create('Magento\Framework\App\Cache\Manager'); + $cacheManager = $this->objectManagerProvider->get()->create(\Magento\Framework\App\Cache\Manager::class); $types = $cacheManager->getAvailableTypes(); $enabledTypes = $cacheManager->setEnabled($types, true); $cacheManager->clean($enabledTypes); @@ -1067,7 +1067,7 @@ class Installer private function cleanCaches() { /** @var \Magento\Framework\App\Cache\Manager $cacheManager */ - $cacheManager = $this->objectManagerProvider->get()->get('Magento\Framework\App\Cache\Manager'); + $cacheManager = $this->objectManagerProvider->get()->get(\Magento\Framework\App\Cache\Manager::class); $types = $cacheManager->getAvailableTypes(); $cacheManager->clean($types); $this->log->log('Cache cleared successfully'); diff --git a/setup/src/Magento/Setup/Model/InstallerFactory.php b/setup/src/Magento/Setup/Model/InstallerFactory.php index 9e0eba3eb1d6c6673220624ae1a677887b7314c9..8a7c2143f0ebce34a175e35812f3931747d7022f 100644 --- a/setup/src/Magento/Setup/Model/InstallerFactory.php +++ b/setup/src/Magento/Setup/Model/InstallerFactory.php @@ -12,6 +12,9 @@ use Magento\Framework\App\ErrorHandler; use Magento\Framework\App\State\CleanupFiles; use Magento\Framework\Setup\LoggerInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class InstallerFactory { /** @@ -50,31 +53,31 @@ class InstallerFactory public function create(LoggerInterface $log) { return new Installer( - $this->serviceLocator->get('Magento\Framework\Setup\FilePermissions'), - $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig\Writer'), - $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig\Reader'), - $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig'), - $this->serviceLocator->get('Magento\Framework\Module\ModuleList'), - $this->serviceLocator->get('Magento\Framework\Module\ModuleList\Loader'), - $this->serviceLocator->get('Magento\Setup\Model\AdminAccountFactory'), + $this->serviceLocator->get(\Magento\Framework\Setup\FilePermissions::class), + $this->serviceLocator->get(\Magento\Framework\App\DeploymentConfig\Writer::class), + $this->serviceLocator->get(\Magento\Framework\App\DeploymentConfig\Reader::class), + $this->serviceLocator->get(\Magento\Framework\App\DeploymentConfig::class), + $this->serviceLocator->get(\Magento\Framework\Module\ModuleList::class), + $this->serviceLocator->get(\Magento\Framework\Module\ModuleList\Loader::class), + $this->serviceLocator->get(\Magento\Setup\Model\AdminAccountFactory::class), $log, - $this->serviceLocator->get('Magento\Setup\Module\ConnectionFactory'), - $this->serviceLocator->get('Magento\Framework\App\MaintenanceMode'), - $this->serviceLocator->get('Magento\Framework\Filesystem'), - $this->serviceLocator->get('Magento\Setup\Model\ObjectManagerProvider'), + $this->serviceLocator->get(\Magento\Setup\Module\ConnectionFactory::class), + $this->serviceLocator->get(\Magento\Framework\App\MaintenanceMode::class), + $this->serviceLocator->get(\Magento\Framework\Filesystem::class), + $this->serviceLocator->get(\Magento\Setup\Model\ObjectManagerProvider::class), new \Magento\Framework\Model\ResourceModel\Db\Context( $this->getResource(), - $this->serviceLocator->get('Magento\Framework\Model\ResourceModel\Db\TransactionManager'), - $this->serviceLocator->get('Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor') + $this->serviceLocator->get(\Magento\Framework\Model\ResourceModel\Db\TransactionManager::class), + $this->serviceLocator->get(\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class) ), - $this->serviceLocator->get('Magento\Setup\Model\ConfigModel'), - $this->serviceLocator->get('Magento\Framework\App\State\CleanupFiles'), - $this->serviceLocator->get('Magento\Setup\Validator\DbValidator'), - $this->serviceLocator->get('Magento\Setup\Module\SetupFactory'), - $this->serviceLocator->get('Magento\Setup\Module\DataSetupFactory'), - $this->serviceLocator->get('Magento\Framework\Setup\SampleData\State'), + $this->serviceLocator->get(\Magento\Setup\Model\ConfigModel::class), + $this->serviceLocator->get(\Magento\Framework\App\State\CleanupFiles::class), + $this->serviceLocator->get(\Magento\Setup\Validator\DbValidator::class), + $this->serviceLocator->get(\Magento\Setup\Module\SetupFactory::class), + $this->serviceLocator->get(\Magento\Setup\Module\DataSetupFactory::class), + $this->serviceLocator->get(\Magento\Framework\Setup\SampleData\State::class), new \Magento\Framework\Component\ComponentRegistrar(), - $this->serviceLocator->get('Magento\Setup\Model\PhpReadinessCheck') + $this->serviceLocator->get(\Magento\Setup\Model\PhpReadinessCheck::class) ); } @@ -85,7 +88,7 @@ class InstallerFactory */ private function getResource() { - $deploymentConfig = $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig'); + $deploymentConfig = $this->serviceLocator->get(\Magento\Framework\App\DeploymentConfig::class); return $this->resourceFactory->create($deploymentConfig); } } diff --git a/setup/src/Magento/Setup/Model/ModuleStatus.php b/setup/src/Magento/Setup/Model/ModuleStatus.php index b0d875b4db98721fa420dc377c8cee999d230ce6..08683ef8f85c356fbd07212842eff2256c9c3ab8 100644 --- a/setup/src/Magento/Setup/Model/ModuleStatus.php +++ b/setup/src/Magento/Setup/Model/ModuleStatus.php @@ -53,7 +53,8 @@ class ModuleStatus $this->allModules[$module]['disabled'] = true; } $this->deploymentConfig = $deploymentConfig; - $this->dependencyChecker = $objectManagerProvider->get()->get('Magento\Framework\Module\DependencyChecker'); + $this->dependencyChecker = $objectManagerProvider->get() + ->get(\Magento\Framework\Module\DependencyChecker::class); } /** diff --git a/setup/src/Magento/Setup/Model/ModuleStatusFactory.php b/setup/src/Magento/Setup/Model/ModuleStatusFactory.php index 44645dde61412eb5de4ae569229ba4dd0db1b921..fe3ff4471fedb146ab2a301962d80869322cdffa 100644 --- a/setup/src/Magento/Setup/Model/ModuleStatusFactory.php +++ b/setup/src/Magento/Setup/Model/ModuleStatusFactory.php @@ -35,6 +35,6 @@ class ModuleStatusFactory */ public function create() { - return $this->objectManagerProvider->get()->get('Magento\Framework\Module\Status'); + return $this->objectManagerProvider->get()->get(\Magento\Framework\Module\Status::class); } } diff --git a/setup/src/Magento/Setup/Model/ModuleUninstaller.php b/setup/src/Magento/Setup/Model/ModuleUninstaller.php index 3e41f1b2da0e1536ab2a12225d59ab216f8565bf..146a54f949425472f4dac81680b7927c14f95d92 100644 --- a/setup/src/Magento/Setup/Model/ModuleUninstaller.php +++ b/setup/src/Magento/Setup/Model/ModuleUninstaller.php @@ -63,7 +63,7 @@ class ModuleUninstaller { $uninstalls = $this->collector->collectUninstall($modules); $setupModel = $this->setupFactory->create(); - $resource = $this->objectManager->get('Magento\Framework\Module\ModuleResource'); + $resource = $this->objectManager->get(\Magento\Framework\Module\ModuleResource::class); foreach ($modules as $module) { if (isset($uninstalls[$module])) { $output->writeln("<info>Removing data of $module</info>"); @@ -89,7 +89,7 @@ class ModuleUninstaller $output->writeln('<info>Removing code from Magento codebase:</info>'); $packages = []; /** @var \Magento\Framework\Module\PackageInfo $packageInfo */ - $packageInfo = $this->objectManager->get('Magento\Framework\Module\PackageInfoFactory')->create(); + $packageInfo = $this->objectManager->get(\Magento\Framework\Module\PackageInfoFactory::class)->create(); foreach ($modules as $module) { $packages[] = $packageInfo->getPackageName($module); } diff --git a/setup/src/Magento/Setup/Model/ThemeDependencyCheckerFactory.php b/setup/src/Magento/Setup/Model/ThemeDependencyCheckerFactory.php index 7c7af94520c66c2c222965acf5f1c6393299f568..305574c6b72e70377510f7927db249839678c8a5 100644 --- a/setup/src/Magento/Setup/Model/ThemeDependencyCheckerFactory.php +++ b/setup/src/Magento/Setup/Model/ThemeDependencyCheckerFactory.php @@ -35,6 +35,6 @@ class ThemeDependencyCheckerFactory */ public function create() { - return $this->objectManagerProvider->get()->get('Magento\Theme\Model\Theme\ThemeDependencyChecker'); + return $this->objectManagerProvider->get()->get(\Magento\Theme\Model\Theme\ThemeDependencyChecker::class); } } diff --git a/setup/src/Magento/Setup/Model/UninstallCollector.php b/setup/src/Magento/Setup/Model/UninstallCollector.php index 37aa3f6c41503fe3d5eb1b9e9bee36638b5e5198..07a07a03c923712f8aeabb4db09ee954b565a3bd 100644 --- a/setup/src/Magento/Setup/Model/UninstallCollector.php +++ b/setup/src/Magento/Setup/Model/UninstallCollector.php @@ -63,7 +63,7 @@ class UninstallCollector $uninstallClassName = str_replace('_', '\\', $row['module']) . '\Setup\Uninstall'; if (class_exists($uninstallClassName)) { $uninstallClass = $this->objectManager->create($uninstallClassName); - if (is_subclass_of($uninstallClass, 'Magento\Framework\Setup\UninstallInterface')) { + if (is_subclass_of($uninstallClass, \Magento\Framework\Setup\UninstallInterface::class)) { $uninstallList[$row['module']] = $uninstallClass; } } diff --git a/setup/src/Magento/Setup/Model/UpdatePackagesCache.php b/setup/src/Magento/Setup/Model/UpdatePackagesCache.php index b63c10f770b41b81fedcda5011eef5f393731639..c1238ef7cefbb032ef60880cbb2c8bf1ab481082 100644 --- a/setup/src/Magento/Setup/Model/UpdatePackagesCache.php +++ b/setup/src/Magento/Setup/Model/UpdatePackagesCache.php @@ -12,6 +12,7 @@ use Magento\Setup\Model\DateTime\DateTimeProvider; /** * Class UpdatePackagesCache manages information about available for update packages though the cache file. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UpdatePackagesCache { @@ -76,7 +77,7 @@ class UpdatePackagesCache DateTimeProvider $dateTimeProvider ) { $applicationFactory = $objectManagerProvider->get() - ->get('Magento\Framework\Composer\MagentoComposerApplicationFactory'); + ->get(\Magento\Framework\Composer\MagentoComposerApplicationFactory::class); $this->application = $applicationFactory->create(); $this->directory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR); $this->dateTime = $dateTimeProvider->get(); diff --git a/setup/src/Magento/Setup/Module.php b/setup/src/Magento/Setup/Module.php index 987d623bfa6b3c71ee2054b68bc716772ff4a95e..f6696ed9d3b6df03b1e52f449290eb08c84e5dc9 100644 --- a/setup/src/Magento/Setup/Module.php +++ b/setup/src/Magento/Setup/Module.php @@ -38,7 +38,7 @@ class Module implements // to process templates by Vendor/Module $injectTemplateListener = new InjectTemplateListener(); $sharedEvents->attach( - 'Zend\Stdlib\DispatchableInterface', + \Zend\Stdlib\DispatchableInterface::class, MvcEvent::EVENT_DISPATCH, [$injectTemplateListener, 'injectTemplate'], -89 diff --git a/setup/src/Magento/Setup/Module/DataSetupFactory.php b/setup/src/Magento/Setup/Module/DataSetupFactory.php index 5fa79d7fb4611afb0e8afff4cb78862a7dbb05c3..95afab3dbddcd693211552ba8d829b925f98ffec 100644 --- a/setup/src/Magento/Setup/Module/DataSetupFactory.php +++ b/setup/src/Magento/Setup/Module/DataSetupFactory.php @@ -35,6 +35,6 @@ class DataSetupFactory public function create() { $objectManager = $this->objectManagerProvider->get(); - return new DataSetup($objectManager->get('Magento\Framework\Module\Setup\Context')); + return new DataSetup($objectManager->get(\Magento\Framework\Module\Setup\Context::class)); } } diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php index b880bc3d8829d2fa38362e0b50ece4197c577867..49fac893b39d4f20ba668b086b6237d740d7e1f7 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php @@ -92,7 +92,7 @@ class Interception implements OperationInterface [ 'ioObject' => $generatorIo, 'generatedEntities' => [ - Interceptor::ENTITY_TYPE => 'Magento\Setup\Module\Di\Code\Generator\Interceptor', + Interceptor::ENTITY_TYPE => \Magento\Setup\Module\Di\Code\Generator\Interceptor::class, ] ] ); diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php b/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php index 9490fc9f6100e8909aa762186814a5a45d67040d..95ae7abac31f6b7056f5569bd4f576ae6873839b 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php @@ -53,13 +53,14 @@ class OperationFactory * @var array */ private $operationsDefinitions = [ - self::DATA_ATTRIBUTES_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\ServiceDataAttributesGenerator', - self::AREA_CONFIG_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\Area', - self::APPLICATION_CODE_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\ApplicationCodeGenerator', - self::INTERCEPTION => 'Magento\Setup\Module\Di\App\Task\Operation\Interception', - self::INTERCEPTION_CACHE => 'Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache', - self::REPOSITORY_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator', - self::PROXY_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\ProxyGenerator', + self::DATA_ATTRIBUTES_GENERATOR => + \Magento\Setup\Module\Di\App\Task\Operation\ServiceDataAttributesGenerator::class, + self::AREA_CONFIG_GENERATOR => \Magento\Setup\Module\Di\App\Task\Operation\Area::class, + self::APPLICATION_CODE_GENERATOR => \Magento\Setup\Module\Di\App\Task\Operation\ApplicationCodeGenerator::class, + self::INTERCEPTION => \Magento\Setup\Module\Di\App\Task\Operation\Interception::class, + self::INTERCEPTION_CACHE => \Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache::class, + self::REPOSITORY_GENERATOR => \Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator::class, + self::PROXY_GENERATOR => \Magento\Setup\Module\Di\App\Task\Operation\ProxyGenerator::class, ]; /** diff --git a/setup/src/Magento/Setup/Module/Di/Code/GeneratorFactory.php b/setup/src/Magento/Setup/Module/Di/Code/GeneratorFactory.php index 95392321920e25e88f9a79903f4b302a1bc469e5..944b7ea744205f57ea4831b531d9a7c749f37f26 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/GeneratorFactory.php +++ b/setup/src/Magento/Setup/Module/Di/Code/GeneratorFactory.php @@ -30,6 +30,6 @@ class GeneratorFactory */ public function create($arguments = []) { - return $this->objectManager->create('Magento\Setup\Module\Di\Code\Generator', $arguments); + return $this->objectManager->create(\Magento\Setup\Module\Di\Code\Generator::class, $arguments); } } diff --git a/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php index ee5a42069fb0cca56c7bac2065ec7f3ac6607182..568e1eae693f86878162f70c28e4215439442e08 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php @@ -66,6 +66,9 @@ class ClassesScanner implements ClassesScannerInterface $fileScanner = new FileScanner($fileItem->getRealPath()); $classNames = $fileScanner->getClassNames(); foreach ($classNames as $className) { + if (empty($className)) { + continue; + } if (!class_exists($className)) { require_once $fileItem->getRealPath(); } diff --git a/setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php index 5293b782064242a571cb7580835abb6586d2a454..da4839f494f6ad63bce500cabfa2af0292215769 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php @@ -316,7 +316,7 @@ class FileScanner extends \Zend\Code\Scanner\FileScanner // process the name if ($infos[$infoIndex]['shortName'] == '' - && (($this->tokenType === T_CLASS || $this->tokenType === T_INTERFACE || $this->tokenType === T_TRAIT) && $infos[$infoIndex]['type'] === 'class' + && (($this->tokenType === T_CLASS || $this->tokenType === T_INTERFACE || $this->tokenType === T_TRAIT) && $infos[$infoIndex]['type'] === 'class' && $tokens[$tokenIndex - 1][0] !== T_DOUBLE_COLON || ($this->tokenType === T_FUNCTION && $infos[$infoIndex]['type'] === 'function')) ) { $infos[$infoIndex]['shortName'] = $tokens[$tokenIndex + 2][1]; diff --git a/setup/src/Magento/Setup/Module/I18n/Dictionary/Options/ResolverFactory.php b/setup/src/Magento/Setup/Module/I18n/Dictionary/Options/ResolverFactory.php index eef6b300bed4ded2faf726904f0152cb18df543a..a0a0e3f09e0e67fc104d8f14154e5b2565fc284f 100644 --- a/setup/src/Magento/Setup/Module/I18n/Dictionary/Options/ResolverFactory.php +++ b/setup/src/Magento/Setup/Module/I18n/Dictionary/Options/ResolverFactory.php @@ -15,7 +15,7 @@ class ResolverFactory /** * Default option resolver class */ - const DEFAULT_RESOLVER = 'Magento\Setup\Module\I18n\Dictionary\Options\Resolver'; + const DEFAULT_RESOLVER = \Magento\Setup\Module\I18n\Dictionary\Options\Resolver::class; /** * @var string diff --git a/setup/src/Magento/Setup/Module/ResourceFactory.php b/setup/src/Magento/Setup/Module/ResourceFactory.php index b40c37faaf53a22a31637f4fd306947b649620a1..31d72ed42705ba393972d9066772765962e3668c 100644 --- a/setup/src/Magento/Setup/Module/ResourceFactory.php +++ b/setup/src/Magento/Setup/Module/ResourceFactory.php @@ -34,7 +34,7 @@ class ResourceFactory */ public function create(\Magento\Framework\App\DeploymentConfig $deploymentConfig) { - $connectionFactory = $this->serviceLocator->get('Magento\Setup\Module\ConnectionFactory'); + $connectionFactory = $this->serviceLocator->get(\Magento\Setup\Module\ConnectionFactory::class); $resource = new ResourceConnection( new ResourceConfig(), $connectionFactory, diff --git a/setup/src/Magento/Setup/Module/SetupFactory.php b/setup/src/Magento/Setup/Module/SetupFactory.php index 999e2fc35768177d7b3411f508b3cf04dab89f0f..f0404bf70032b7d0f58057daeda1a30635366c6f 100644 --- a/setup/src/Magento/Setup/Module/SetupFactory.php +++ b/setup/src/Magento/Setup/Module/SetupFactory.php @@ -38,7 +38,7 @@ class SetupFactory { $objectManager = $this->objectManagerProvider->get(); if ($appResource === null) { - $appResource = $objectManager->get('Magento\Framework\App\ResourceConnection'); + $appResource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class); } return new Setup($appResource); } diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 777f87515d665461884263f4366372b4dd8ad9b9..149cfe61a55a234f89847c8b276f6f3139b7b4eb 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -47,8 +47,8 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface * @var array */ private $controllersToSkip = [ - 'Magento\Setup\Controller\Session', - 'Magento\Setup\Controller\Success' + \Magento\Setup\Controller\Session::class, + \Magento\Setup\Controller\Success::class ]; /** @@ -58,7 +58,7 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface { $sharedEvents = $events->getSharedManager(); $this->listeners[] = $sharedEvents->attach( - 'Zend\Mvc\Application', + \Zend\Mvc\Application::class, MvcEvent::EVENT_BOOTSTRAP, [$this, 'onBootstrap'] ); @@ -89,8 +89,8 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface $initParams = $application->getServiceManager()->get(self::BOOTSTRAP_PARAM); $directoryList = $this->createDirectoryList($initParams); $serviceManager = $application->getServiceManager(); - $serviceManager->setService('Magento\Framework\App\Filesystem\DirectoryList', $directoryList); - $serviceManager->setService('Magento\Framework\Filesystem', $this->createFilesystem($directoryList)); + $serviceManager->setService(\Magento\Framework\App\Filesystem\DirectoryList::class, $directoryList); + $serviceManager->setService(\Magento\Framework\Filesystem::class, $this->createFilesystem($directoryList)); if (!($application->getRequest() instanceof Request)) { $eventManager = $application->getEventManager(); @@ -115,13 +115,13 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface /** @var Application $application */ $application = $event->getApplication(); $serviceManager = $application->getServiceManager(); - if ($serviceManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { + if ($serviceManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) { /** @var \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider */ - $objectManagerProvider = $serviceManager->get('Magento\Setup\Model\ObjectManagerProvider'); + $objectManagerProvider = $serviceManager->get(\Magento\Setup\Model\ObjectManagerProvider::class); /** @var \Magento\Framework\ObjectManagerInterface $objectManager */ $objectManager = $objectManagerProvider->get(); /** @var \Magento\Framework\App\State $adminAppState */ - $adminAppState = $objectManager->get('Magento\Framework\App\State'); + $adminAppState = $objectManager->get(\Magento\Framework\App\State::class); $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); /** @var \Magento\Backend\Model\Session\AdminConfig $sessionConfig */ $sessionConfig = $objectManager->get(\Magento\Backend\Model\Session\AdminConfig::class); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php index f648dda8877d7fc862d7c44ae3c48acfaa7053de..f274d354ba43f358e6c8036ac06124e65220ccb4 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php @@ -25,7 +25,7 @@ class AdminUserCreateCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->installerFactoryMock = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); + $this->installerFactoryMock = $this->getMock(\Magento\Setup\Model\InstallerFactory::class, [], [], '', false); $this->command = new AdminUserCreateCommand($this->installerFactoryMock, new UserValidationRules()); } @@ -47,7 +47,7 @@ class AdminUserCreateCommandTest extends \PHPUnit_Framework_TestCase InitParamListener::BOOTSTRAP_PARAM => null, ]; $commandTester = new CommandTester($this->command); - $installerMock = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); + $installerMock = $this->getMock(\Magento\Setup\Model\Installer::class, [], [], '', false); $installerMock->expects($this->once())->method('installAdminUser')->with($data); $this->installerFactoryMock->expects($this->once())->method('create')->willReturn($installerMock); $commandTester->execute($options); @@ -68,7 +68,12 @@ class AdminUserCreateCommandTest extends \PHPUnit_Framework_TestCase */ public function testValidate(array $options, array $errors) { - $inputMock = $this->getMockForAbstractClass('Symfony\Component\Console\Input\InputInterface', [], '', false); + $inputMock = $this->getMockForAbstractClass( + \Symfony\Component\Console\Input\InputInterface::class, + [], + '', + false + ); $index = 0; foreach ($options as $option) { $inputMock->expects($this->at($index++))->method('getOption')->willReturn($option); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php index f356713a444fa3e16fcaca181737eacfee8af099..38329a897775ed5f2c971561bc5c724ebd4e217a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php @@ -37,18 +37,18 @@ class BackupCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false ); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); - $this->backupRollback = $this->getMock('Magento\Framework\Setup\BackupRollback', [], [], '', false); + $this->backupRollback = $this->getMock(\Magento\Framework\Setup\BackupRollback::class, [], [], '', false); $this->backupRollbackFactory = $this->getMock( - 'Magento\Framework\Setup\BackupRollbackFactory', + \Magento\Framework\Setup\BackupRollbackFactory::class, [], [], '', @@ -57,16 +57,16 @@ class BackupCommandTest extends \PHPUnit_Framework_TestCase $this->backupRollbackFactory->expects($this->any()) ->method('create') ->willReturn($this->backupRollback); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $appState = $this->getMock( - 'Magento\Framework\App\State', + \Magento\Framework\App\State::class, [], [], '', false ); $configLoader = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManager\ConfigLoaderInterface', + \Magento\Framework\ObjectManager\ConfigLoaderInterface::class, [], '', false @@ -77,9 +77,9 @@ class BackupCommandTest extends \PHPUnit_Framework_TestCase ->method('get') ->will( $this->returnValueMap([ - ['Magento\Framework\Setup\BackupRollbackFactory', $this->backupRollbackFactory], - ['Magento\Framework\App\State', $appState], - ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], + [\Magento\Framework\Setup\BackupRollbackFactory::class, $this->backupRollbackFactory], + [\Magento\Framework\App\State::class, $appState], + [\Magento\Framework\ObjectManager\ConfigLoaderInterface::class, $configLoader], ]) ); $command = new BackupCommand( diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php index 0877d057d31d18ea209ca108e616ff4c022a7380..9d611d080ffc16bff3b49fb17f7a043e074f8d5e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php @@ -29,18 +29,18 @@ class ConfigSetCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $option = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option ->expects($this->any()) ->method('getName') ->will($this->returnValue('db-host')); - $this->configModel = $this->getMock('Magento\Setup\Model\ConfigModel', [], [], '', false); + $this->configModel = $this->getMock(\Magento\Setup\Model\ConfigModel::class, [], [], '', false); $this->configModel ->expects($this->exactly(2)) ->method('getAvailableOptions') ->will($this->returnValue([$option])); - $moduleList = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $moduleList = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $this->command = new ConfigSetCommand($this->configModel, $moduleList, $this->deploymentConfig); } @@ -96,14 +96,14 @@ class ConfigSetCommandTest extends \PHPUnit_Framework_TestCase */ private function checkInteraction($interactionType) { - $dialog = $this->getMock('Symfony\Component\Console\Helper\DialogHelper', [], [], '', false); + $dialog = $this->getMock(\Symfony\Component\Console\Helper\DialogHelper::class, [], [], '', false); $dialog ->expects($this->once()) ->method('askConfirmation') ->will($this->returnValue($interactionType)); /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ - $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet = $this->getMock(\Symfony\Component\Console\Helper\HelperSet::class, [], [], '', false); $helperSet ->expects($this->once()) ->method('get') diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/CronRunCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/CronRunCommandTest.php index 3a29130017af5b61b3bee6017b2a772af6b5e591..c9a060bb070c7aefc8e653a1861f7cec1f906ba6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/CronRunCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/CronRunCommandTest.php @@ -43,10 +43,10 @@ class CronRunCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->queue = $this->getMock('Magento\Setup\Model\Cron\Queue', [], [], '', false); - $this->readinessCheck = $this->getMock('Magento\Setup\Model\Cron\ReadinessCheck', [], [], '', false); - $this->status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->queue = $this->getMock(\Magento\Setup\Model\Cron\Queue::class, [], [], '', false); + $this->readinessCheck = $this->getMock(\Magento\Setup\Model\Cron\ReadinessCheck::class, [], [], '', false); + $this->status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); $this->command = new CronRunCommand( $this->deploymentConfig, $this->queue, @@ -150,7 +150,7 @@ class CronRunCommandTest extends \PHPUnit_Framework_TestCase $this->setUpPreliminarySuccess(); $this->queue->expects($this->at(0))->method('peek')->willReturn(['name' => 'setup:']); $this->queue->expects($this->at(1))->method('peek')->willReturn(['name' => 'setup:']); - $job = $this->getMockForAbstractClass('Magento\Setup\Model\Cron\AbstractJob', [], '', false); + $job = $this->getMockForAbstractClass(\Magento\Setup\Model\Cron\AbstractJob::class, [], '', false); $job->expects($this->once())->method('execute')->willThrowException(new \Exception('job failed')); $this->queue->expects($this->at(2))->method('popQueuedJob')->willReturn($job); $this->status->expects($this->atLeastOnce())->method('toggleUpdateError')->with(true); @@ -162,7 +162,7 @@ class CronRunCommandTest extends \PHPUnit_Framework_TestCase $this->setUpPreliminarySuccess(); $this->queue->expects($this->at(0))->method('peek')->willReturn(['name' => 'setup:']); $this->queue->expects($this->at(1))->method('peek')->willReturn(['name' => 'setup:']); - $job = $this->getMockForAbstractClass('Magento\Setup\Model\Cron\AbstractJob', [], '', false); + $job = $this->getMockForAbstractClass(\Magento\Setup\Model\Cron\AbstractJob::class, [], '', false); $job->expects($this->once())->method('execute'); $this->queue->expects($this->at(2))->method('popQueuedJob')->willReturn($job); $this->status->expects($this->never())->method('toggleUpdateError')->with(true); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DbDataUpgradeCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DbDataUpgradeCommandTest.php index eba21e10ea1b0c40b2220fb7e156cc94ed830050..d31ca01b0f8f63bd88114a75de15da66c3648179 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DbDataUpgradeCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DbDataUpgradeCommandTest.php @@ -24,14 +24,14 @@ class DbDataUpgradeCommandTest extends \PHPUnit_Framework_TestCase protected function setup() { - $this->installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->installerFactory = $this->getMock(\Magento\Setup\Model\InstallerFactory::class, [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); } public function testExecute() { $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true)); - $installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); + $installer = $this->getMock(\Magento\Setup\Model\Installer::class, [], [], '', false); $this->installerFactory->expects($this->once())->method('create')->will($this->returnValue($installer)); $installer->expects($this->once())->method('installDataFixtures'); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DbSchemaUpgradeCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DbSchemaUpgradeCommandTest.php index c4ea7712f086d08a8ae2bccc864ec4c4c41ff1b0..ac453cb450c6dd58d4b1c11604d18a401428f129 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DbSchemaUpgradeCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DbSchemaUpgradeCommandTest.php @@ -15,7 +15,7 @@ class DbSchemaUpgradeCommandTest extends DbDataUpgradeCommandTest public function testExecute() { $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true)); - $installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); + $installer = $this->getMock(\Magento\Setup\Model\Installer::class, [], [], '', false); $this->installerFactory->expects($this->once())->method('create')->will($this->returnValue($installer)); $installer->expects($this->once())->method('installSchema'); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php index 943d3a4cb5b2485349e5633dcb64ba17cf1cb32d..0d3a19e803d3c1d634196d2f149ff09f6f3c1150 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php @@ -28,16 +28,16 @@ class DbStatusCommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dbVersionInfo = $this->getMock('Magento\Framework\Module\DbVersionInfo', [], [], '', false); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $this->dbVersionInfo = $this->getMock(\Magento\Framework\Module\DbVersionInfo::class, [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $objectManagerProvider->expects($this->any()) ->method('get') ->will($this->returnValue($objectManager)); $objectManager->expects($this->any()) ->method('get') ->will($this->returnValue($this->dbVersionInfo)); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $this->command = new DbStatusCommand($objectManagerProvider, $this->deploymentConfig); } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php index 31b86e7cec70cdb422a4fd07a1133ab5cf136e50..22df0b92a39840892b4b30c2f892a2d92f1deea1 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php @@ -9,6 +9,9 @@ use Magento\Framework\Component\ComponentRegistrar; use Magento\Setup\Console\Command\DiCompileCommand; use Symfony\Component\Console\Tester\CommandTester; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DiCompileCommandTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */ @@ -40,38 +43,39 @@ class DiCompileCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->deploymentConfigMock = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $objectManagerProviderMock = $this->getMock( - 'Magento\Setup\Model\ObjectManagerProvider', + \Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false ); $this->objectManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false ); - $this->cacheMock = $this->getMockBuilder('Magento\Framework\App\Cache') + $this->cacheMock = $this->getMockBuilder(\Magento\Framework\App\Cache::class) ->disableOriginalConstructor() ->getMock(); $objectManagerProviderMock->expects($this->once()) ->method('get') ->willReturn($this->objectManagerMock); - $this->managerMock = $this->getMock('Magento\Setup\Module\Di\App\Task\Manager', [], [], '', false); - $this->directoryListMock = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); - $this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + $this->managerMock = $this->getMock(\Magento\Setup\Module\Di\App\Task\Manager::class, [], [], '', false); + $this->directoryListMock = + $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); + $this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $this->fileDriverMock = $this->getMockBuilder('Magento\Framework\Filesystem\Driver\File') + $this->fileDriverMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Driver\File::class) ->disableOriginalConstructor() ->getMock(); $this->componentRegistrarMock = $this->getMock( - '\Magento\Framework\Component\ComponentRegistrar', + \Magento\Framework\Component\ComponentRegistrar::class, [], [], '', @@ -113,10 +117,10 @@ class DiCompileCommandTest extends \PHPUnit_Framework_TestCase $this->directoryListMock->expects($this->atLeastOnce())->method('getPath')->willReturn(null); $this->objectManagerMock->expects($this->once()) ->method('get') - ->with('Magento\Framework\App\Cache') + ->with(\Magento\Framework\App\Cache::class) ->willReturn($this->cacheMock); $this->cacheMock->expects($this->once())->method('clean'); - $writeDirectory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface'); + $writeDirectory = $this->getMock(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $writeDirectory->expects($this->atLeastOnce())->method('delete'); $this->filesystemMock->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory); @@ -125,7 +129,7 @@ class DiCompileCommandTest extends \PHPUnit_Framework_TestCase ->with(\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES) ->willReturn(['Magento_Catalog' => 1]); $progressBar = $this->getMockBuilder( - 'Symfony\Component\Console\Helper\ProgressBar' + \Symfony\Component\Console\Helper\ProgressBar::class ) ->disableOriginalConstructor() ->getMock(); @@ -134,7 +138,7 @@ class DiCompileCommandTest extends \PHPUnit_Framework_TestCase $this->objectManagerMock ->expects($this->once()) ->method('create') - ->with('Symfony\Component\Console\Helper\ProgressBar') + ->with(\Symfony\Component\Console\Helper\ProgressBar::class) ->willReturn($progressBar); $this->managerMock->expects($this->exactly(7))->method('addOperation'); $this->managerMock->expects($this->once())->method('process'); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/GenerateFixturesCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/GenerateFixturesCommandTest.php index cb7828c7dcb7199d72cf4e1513cef583c3652993..64b857cf9b300803b07c996dd9be71380a18eb6c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/GenerateFixturesCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/GenerateFixturesCommandTest.php @@ -24,7 +24,7 @@ class GenerateFixturesCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModel = $this->getMock('Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModel = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->command = new GenerateFixturesCommand($this->fixtureModel); } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoAdminUriCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoAdminUriCommandTest.php index 3d3eda0a815e2b9e4a82b04427fe6dcc600fa5aa..f63c8cc8fcf59418f22a497dcadbd89574d68f3a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoAdminUriCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoAdminUriCommandTest.php @@ -18,7 +18,7 @@ class InfoAdminUriCommandTest extends \PHPUnit_Framework_TestCase protected function setup() { - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); } public function testExecute() diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoBackupsListCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoBackupsListCommandTest.php index 78bccd796e521a4f44aff8467cd9a1a501b320c4..5b59e141c4fdb0844840137faa02342aad406e1f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoBackupsListCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoBackupsListCommandTest.php @@ -13,18 +13,18 @@ class InfoBackupsListCommandTest extends \PHPUnit_Framework_TestCase { public function testExecute() { - $table = $this->getMock('Symfony\Component\Console\Helper\Table', [], [], '', false); + $table = $this->getMock(\Symfony\Component\Console\Helper\Table::class, [], [], '', false); $table->expects($this->once())->method('setHeaders')->with(['Backup Filename', 'Backup Type']); $table->expects($this->once())->method('addRow')->with(['backupFile_media.tgz', 'media']); /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ - $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet = $this->getMock(\Symfony\Component\Console\Helper\HelperSet::class, [], [], '', false); $helperSet->expects($this->once())->method('get')->with('table')->will($this->returnValue($table)); /** @var \Magento\Framework\App\Filesystem\DirectoryList * |\PHPUnit_Framework_MockObject_MockObject $directoryList */ - $directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $directoryList = $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); /** @var \Magento\Framework\Filesystem\Driver\File|\PHPUnit_Framework_MockObject_MockObject $file */ - $file = $this->getMock('Magento\Framework\Filesystem\Driver\File', [], [], '', false); + $file = $this->getMock(\Magento\Framework\Filesystem\Driver\File::class, [], [], '', false); $file->expects($this->once())->method('isExists')->will($this->returnValue(true)); $file->expects($this->once()) ->method('readDirectoryRecursively') diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoCurrencyListCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoCurrencyListCommandTest.php index 9d5be0908acb07859e974b0e0b4c1d713b2d2d1e..52255274428f1460fbb7c9ab77d6297167314569 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoCurrencyListCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoCurrencyListCommandTest.php @@ -17,16 +17,16 @@ class InfoCurrencyListCommandTest extends \PHPUnit_Framework_TestCase 'CUR' => 'Currency description' ]; - $table = $this->getMock('Symfony\Component\Console\Helper\Table', [], [], '', false); + $table = $this->getMock(\Symfony\Component\Console\Helper\Table::class, [], [], '', false); $table->expects($this->once())->method('setHeaders')->with(['Currency', 'Code']); $table->expects($this->once())->method('addRow')->with(['Currency description', 'CUR']); /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ - $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet = $this->getMock(\Symfony\Component\Console\Helper\HelperSet::class, [], [], '', false); $helperSet->expects($this->once())->method('get')->with('table')->will($this->returnValue($table)); /** @var \Magento\Framework\Setup\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ - $list = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $list = $this->getMock(\Magento\Framework\Setup\Lists::class, [], [], '', false); $list->expects($this->once())->method('getCurrencyList')->will($this->returnValue($currencies)); $command = new InfoCurrencyListCommand($list); $command->setHelperSet($helperSet); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoLanguageListCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoLanguageListCommandTest.php index 94c47e8ba7b4b14c44f787bd0bbb1c343c0ed905..a00aac14e4f9fed8bf35b951c4249f06c4d8beae 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoLanguageListCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoLanguageListCommandTest.php @@ -17,16 +17,16 @@ class InfoLanguageListCommandTest extends \PHPUnit_Framework_TestCase 'LNG' => 'Language description' ]; - $table = $this->getMock('Symfony\Component\Console\Helper\Table', [], [], '', false); + $table = $this->getMock(\Symfony\Component\Console\Helper\Table::class, [], [], '', false); $table->expects($this->once())->method('setHeaders')->with(['Language', 'Code']); $table->expects($this->once())->method('addRow')->with(['Language description', 'LNG']); /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ - $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet = $this->getMock(\Symfony\Component\Console\Helper\HelperSet::class, [], [], '', false); $helperSet->expects($this->once())->method('get')->with('table')->will($this->returnValue($table)); /** @var \Magento\Framework\Setup\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ - $list = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $list = $this->getMock(\Magento\Framework\Setup\Lists::class, [], [], '', false); $list->expects($this->once())->method('getLocaleList')->will($this->returnValue($languages)); $command = new InfoLanguageListCommand($list); $command->setHelperSet($helperSet); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoTimezoneListCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoTimezoneListCommandTest.php index 0cdb2bb3a1f89742442aac4536257fecdeeb2230..56f4e8230aa911a09f0da2c252da8ba0695fcf31 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoTimezoneListCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoTimezoneListCommandTest.php @@ -17,16 +17,16 @@ class InfoTimezoneListCommandTest extends \PHPUnit_Framework_TestCase 'timezone' => 'timezone description' ]; - $table = $this->getMock('Symfony\Component\Console\Helper\Table', [], [], '', false); + $table = $this->getMock(\Symfony\Component\Console\Helper\Table::class, [], [], '', false); $table->expects($this->once())->method('setHeaders')->with(['Timezone', 'Code']); $table->expects($this->once())->method('addRow')->with(['timezone description', 'timezone']); /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ - $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet = $this->getMock(\Symfony\Component\Console\Helper\HelperSet::class, [], [], '', false); $helperSet->expects($this->once())->method('get')->with('table')->will($this->returnValue($table)); /** @var \Magento\Framework\Setup\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ - $list = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $list = $this->getMock(\Magento\Framework\Setup\Lists::class, [], [], '', false); $list->expects($this->once())->method('getTimezoneList')->will($this->returnValue($timezones)); $command = new InfoTimezoneListCommand($list); $command->setHelperSet($helperSet); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallCommandTest.php index 9ef538662ff20a9dad0749a7205d839fefb6757b..754913f4d627eadb11bfdd3817512aee2435eab8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallCommandTest.php @@ -13,6 +13,9 @@ use Magento\Backend\Setup\ConfigOptionsList as BackendConfigOptionsList; use Magento\Framework\Config\ConfigOptionsListConstants as SetupConfigOptionsList; use Magento\Setup\Model\StoreConfigurationDataMapper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class InstallCommandTest extends \PHPUnit_Framework_TestCase { /** @@ -53,7 +56,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase '--' . AdminAccount::KEY_LAST_NAME => 'Doe', ]; - $configModel = $this->getMock('Magento\Setup\Model\ConfigModel', [], [], '', false); + $configModel = $this->getMock(\Magento\Setup\Model\ConfigModel::class, [], [], '', false); $configModel ->expects($this->exactly(2)) ->method('getAvailableOptions') @@ -64,7 +67,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue([])); $userConfig = $this->getMock( - 'Magento\Setup\Console\Command\InstallStoreConfigurationCommand', + \Magento\Setup\Console\Command\InstallStoreConfigurationCommand::class, [], [], '', @@ -79,7 +82,7 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase ->method('validate') ->will($this->returnValue([])); - $adminUser = $this->getMock('Magento\Setup\Console\Command\AdminUserCreateCommand', [], [], '', false); + $adminUser = $this->getMock(\Magento\Setup\Console\Command\AdminUserCreateCommand::class, [], [], '', false); $adminUser ->expects($this->once()) ->method('getOptionsList') @@ -89,8 +92,8 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase ->method('validate') ->will($this->returnValue([])); - $this->installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); - $this->installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); + $this->installerFactory = $this->getMock(\Magento\Setup\Model\InstallerFactory::class, [], [], '', false); + $this->installer = $this->getMock(\Magento\Setup\Model\Installer::class, [], [], '', false); $this->command = new InstallCommand( $this->installerFactory, $configModel, @@ -117,22 +120,22 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase */ private function getOptionsListDeployConfig() { - $option1 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option1 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option1 ->expects($this->any()) ->method('getName') ->will($this->returnValue(SetupConfigOptionsList::INPUT_KEY_DB_HOST)); - $option2 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option2 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option2 ->expects($this->any()) ->method('getName') ->will($this->returnValue(SetupConfigOptionsList::INPUT_KEY_DB_NAME)); - $option3 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option3 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option3 ->expects($this->any()) ->method('getName') ->will($this->returnValue(SetupConfigOptionsList::INPUT_KEY_DB_USER)); - $option4 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option4 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option4 ->expects($this->any()) ->method('getName') @@ -147,22 +150,22 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase */ private function getOptionsListUserConfig() { - $option1 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option1 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option1 ->expects($this->any()) ->method('getName') ->will($this->returnValue(StoreConfigurationDataMapper::KEY_BASE_URL)); - $option2 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option2 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option2 ->expects($this->any()) ->method('getName') ->will($this->returnValue(StoreConfigurationDataMapper::KEY_LANGUAGE)); - $option3 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option3 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option3 ->expects($this->any()) ->method('getName') ->will($this->returnValue(StoreConfigurationDataMapper::KEY_TIMEZONE)); - $option4 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option4 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option4 ->expects($this->any()) ->method('getName') @@ -177,27 +180,27 @@ class InstallCommandTest extends \PHPUnit_Framework_TestCase */ private function getOptionsListAdminUser() { - $option1 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option1 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option1 ->expects($this->any()) ->method('getName') ->will($this->returnValue(AdminAccount::KEY_USER)); - $option2 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option2 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option2 ->expects($this->any()) ->method('getName') ->will($this->returnValue(AdminAccount::KEY_PASSWORD)); - $option3 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option3 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option3 ->expects($this->any()) ->method('getName') ->will($this->returnValue(AdminAccount::KEY_EMAIL)); - $option4 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option4 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option4 ->expects($this->any()) ->method('getName') ->will($this->returnValue(AdminAccount::KEY_FIRST_NAME)); - $option5 = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option5 = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option5 ->expects($this->any()) ->method('getName') diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallStoreConfigurationCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallStoreConfigurationCommandTest.php index e8de226815e7901a2f95a4d5cca289641c2e71bb..6f5ab3a5a64c537751cc8964229e35869b06c8e5 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallStoreConfigurationCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallStoreConfigurationCommandTest.php @@ -42,18 +42,18 @@ class InstallStoreConfigurationCommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); + $this->installerFactory = $this->getMock(\Magento\Setup\Model\InstallerFactory::class, [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->installer = $this->getMock(\Magento\Setup\Model\Installer::class, [], [], '', false); $objectManagerProvider = $this->getMock( - 'Magento\Setup\Model\ObjectManagerProvider', + \Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false ); $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false @@ -102,35 +102,35 @@ class InstallStoreConfigurationCommandTest extends \PHPUnit_Framework_TestCase */ public function testExecuteInvalidData(array $option, $error) { - $url= $this->getMock('Magento\Framework\Url\Validator', [], [], '', false); + $url= $this->getMock(\Magento\Framework\Url\Validator::class, [], [], '', false); $url->expects($this->any())->method('isValid')->will($this->returnValue(false)); if (!isset($option['--' . StoreConfigurationDataMapper::KEY_BASE_URL_SECURE])) { $url->expects($this->any())->method('getMessages')->will($this->returnValue([ Validator::INVALID_URL => 'Invalid URL.' ])); } - $localeLists= $this->getMock('Magento\Framework\Validator\Locale', [], [], '', false); + $localeLists= $this->getMock(\Magento\Framework\Validator\Locale::class, [], [], '', false); $localeLists->expects($this->any())->method('isValid')->will($this->returnValue(false)); - $timezoneLists= $this->getMock('Magento\Framework\Validator\Timezone', [], [], '', false); + $timezoneLists= $this->getMock(\Magento\Framework\Validator\Timezone::class, [], [], '', false); $timezoneLists->expects($this->any())->method('isValid')->will($this->returnValue(false)); - $currencyLists= $this->getMock('Magento\Framework\Validator\Currency', [], [], '', false); + $currencyLists= $this->getMock(\Magento\Framework\Validator\Currency::class, [], [], '', false); $currencyLists->expects($this->any())->method('isValid')->will($this->returnValue(false)); $returnValueMapOM = [ [ - 'Magento\Framework\Url\Validator', + \Magento\Framework\Url\Validator::class, $url ], [ - 'Magento\Framework\Validator\Locale', + \Magento\Framework\Validator\Locale::class, $localeLists ], [ - 'Magento\Framework\Validator\Timezone', + \Magento\Framework\Validator\Timezone::class, $timezoneLists ], [ - 'Magento\Framework\Validator\Currency', + \Magento\Framework\Validator\Currency::class, $currencyLists ], ]; diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php index f60df4064d9182800e9ac4a150b2ea6642a5d01b..126cbadb6a53b67e644eb1768873471f21a4eae8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php @@ -29,8 +29,8 @@ class MaintenanceAllowIpsCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $this->ipValidator = $this->getMock('Magento\Setup\Validator\IpValidator', [], [], '', false); + $this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); + $this->ipValidator = $this->getMock(\Magento\Setup\Validator\IpValidator::class, [], [], '', false); $this->command = new MaintenanceAllowIpsCommand($this->maintenanceMode, $this->ipValidator); } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceDisableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceDisableCommandTest.php index e7f9f7ddb29212595616a4b7555ad0858cf25742..9d23b225845c5c4fdf47f698e34554a5d9f6b351 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceDisableCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceDisableCommandTest.php @@ -29,8 +29,8 @@ class MaintenanceDisableCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $this->ipValidator = $this->getMock('Magento\Setup\Validator\IpValidator', [], [], '', false); + $this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); + $this->ipValidator = $this->getMock(\Magento\Setup\Validator\IpValidator::class, [], [], '', false); $this->command = new MaintenanceDisableCommand($this->maintenanceMode, $this->ipValidator); } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceEnableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceEnableCommandTest.php index 7e8c0028f652c4a903d703b927b9c69ed96c8288..e9ad6384a05e192d0df87fc3c39accfd572656b6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceEnableCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceEnableCommandTest.php @@ -29,8 +29,8 @@ class MaintenanceEnableCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $this->ipValidator = $this->getMock('Magento\Setup\Validator\IpValidator', [], [], '', false); + $this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); + $this->ipValidator = $this->getMock(\Magento\Setup\Validator\IpValidator::class, [], [], '', false); $this->command = new MaintenanceEnableCommand($this->maintenanceMode, $this->ipValidator); } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceStatusCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceStatusCommandTest.php index 00a12b078feda1ffa74714b925aeff3914d9dc15..740f41bdfd3bd54c045effcff6daca389ac85af0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceStatusCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceStatusCommandTest.php @@ -23,7 +23,7 @@ class MaintenanceStatusCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); + $this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); $this->command = new MaintenanceStatusCommand($this->maintenanceMode); } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php index 41b05cc302b19ccead2e3dea116afdceabceb95d..8ef2151817b2ca3612bf894b38e779ec6b5cf7e5 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php @@ -44,28 +44,28 @@ class ModuleEnableDisableCommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerProviderMock = $this->getMock( - 'Magento\Setup\Model\ObjectManagerProvider', + \Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false ); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerProviderMock->expects($this->any()) ->method('get') ->will($this->returnValue($objectManager)); - $this->statusMock = $this->getMock('Magento\Framework\Module\Status', [], [], '', false); - $this->cacheMock = $this->getMock('Magento\Framework\App\Cache', [], [], '', false); - $this->cleanupFilesMock = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); - $this->fullModuleListMock = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); + $this->statusMock = $this->getMock(\Magento\Framework\Module\Status::class, [], [], '', false); + $this->cacheMock = $this->getMock(\Magento\Framework\App\Cache::class, [], [], '', false); + $this->cleanupFilesMock = $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, [], [], '', false); + $this->fullModuleListMock = $this->getMock(\Magento\Framework\Module\FullModuleList::class, [], [], '', false); $this->deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ - ['Magento\Framework\Module\Status', $this->statusMock], - ['Magento\Framework\App\Cache', $this->cacheMock], - ['Magento\Framework\App\State\CleanupFiles', $this->cleanupFilesMock], - ['Magento\Framework\Module\FullModuleList', $this->fullModuleListMock], + [\Magento\Framework\Module\Status::class, $this->statusMock], + [\Magento\Framework\App\Cache::class, $this->cacheMock], + [\Magento\Framework\App\State\CleanupFiles::class, $this->cleanupFilesMock], + [\Magento\Framework\Module\FullModuleList::class, $this->fullModuleListMock], ])); } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleStatusCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleStatusCommandTest.php index b8403cb5329a53c7e61783e661fe40908c8a6c85..5aefd51578f17b47c717f697e65b6b21fa59ac94 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleStatusCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleStatusCommandTest.php @@ -12,18 +12,18 @@ class ModuleStatusCommandTest extends \PHPUnit_Framework_TestCase { public function testExecute() { - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $objectManagerProvider->expects($this->any()) ->method('get') ->will($this->returnValue($objectManager)); - $moduleList = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); - $fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); + $moduleList = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); + $fullModuleList = $this->getMock(\Magento\Framework\Module\FullModuleList::class, [], [], '', false); $objectManager->expects($this->any()) ->method('create') ->will($this->returnValueMap([ - ['Magento\Framework\Module\ModuleList', [], $moduleList], - ['Magento\Framework\Module\FullModuleList', [], $fullModuleList], + [\Magento\Framework\Module\ModuleList::class, [], $moduleList], + [\Magento\Framework\Module\FullModuleList::class, [], $fullModuleList], ])); $moduleList->expects($this->any()) ->method('getNames') diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleUninstallCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleUninstallCommandTest.php index 7a992ec868a5e906eba04275933c03a7cdd29f59..47e4251fe6d7c93c05123804ef027499b6292625 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleUninstallCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleUninstallCommandTest.php @@ -100,19 +100,30 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); - $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); - $this->uninstallCollector = $this->getMock('Magento\Setup\Model\UninstallCollector', [], [], '', false); - $this->packageInfo = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); - $packageInfoFactory = $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->fullModuleList = $this->getMock(\Magento\Framework\Module\FullModuleList::class, [], [], '', false); + $this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = $this->getMockForAbstractClass( + \Magento\Framework\ObjectManagerInterface::class, + [], + '', + false + ); + $this->uninstallCollector = $this->getMock(\Magento\Setup\Model\UninstallCollector::class, [], [], '', false); + $this->packageInfo = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); + $packageInfoFactory = $this->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false); $packageInfoFactory->expects($this->once())->method('create')->willReturn($this->packageInfo); - $this->dependencyChecker = $this->getMock('Magento\Framework\Module\DependencyChecker', [], [], '', false); - $this->backupRollback = $this->getMock('Magento\Framework\Setup\BackupRollback', [], [], '', false); + $this->dependencyChecker = $this->getMock( + \Magento\Framework\Module\DependencyChecker::class, + [], + [], + '', + false + ); + $this->backupRollback = $this->getMock(\Magento\Framework\Setup\BackupRollback::class, [], [], '', false); $this->backupRollbackFactory = $this->getMock( - 'Magento\Framework\Setup\BackupRollbackFactory', + \Magento\Framework\Setup\BackupRollbackFactory::class, [], [], '', @@ -121,11 +132,11 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->backupRollbackFactory->expects($this->any()) ->method('create') ->willReturn($this->backupRollback); - $this->cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', false); - $this->cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); + $this->cache = $this->getMock(\Magento\Framework\App\Cache::class, [], [], '', false); + $this->cleanupFiles = $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($objectManager); $configLoader = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManager\ConfigLoaderInterface', + \Magento\Framework\ObjectManager\ConfigLoaderInterface::class, [], '', false @@ -134,21 +145,24 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ - ['Magento\Framework\Module\PackageInfoFactory', $packageInfoFactory], - ['Magento\Framework\Module\DependencyChecker', $this->dependencyChecker], - ['Magento\Framework\App\Cache', $this->cache], - ['Magento\Framework\App\State\CleanupFiles', $this->cleanupFiles], - ['Magento\Framework\App\State', $this->getMock('Magento\Framework\App\State', [], [], '', false)], - ['Magento\Framework\Setup\BackupRollbackFactory', $this->backupRollbackFactory], - ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], + [\Magento\Framework\Module\PackageInfoFactory::class, $packageInfoFactory], + [\Magento\Framework\Module\DependencyChecker::class, $this->dependencyChecker], + [\Magento\Framework\App\Cache::class, $this->cache], + [\Magento\Framework\App\State\CleanupFiles::class, $this->cleanupFiles], + [ + \Magento\Framework\App\State::class, + $this->getMock(\Magento\Framework\App\State::class, [], [], '', false) + ], + [\Magento\Framework\Setup\BackupRollbackFactory::class, $this->backupRollbackFactory], + [\Magento\Framework\ObjectManager\ConfigLoaderInterface::class, $configLoader], ])); - $composer = $this->getMock('Magento\Framework\Composer\ComposerInformation', [], [], '', false); + $composer = $this->getMock(\Magento\Framework\Composer\ComposerInformation::class, [], [], '', false); $composer->expects($this->any()) ->method('getRootRequiredPackages') ->willReturn(['magento/package-a', 'magento/package-b']); - $this->moduleUninstaller = $this->getMock('Magento\Setup\Model\ModuleUninstaller', [], [], '', false); + $this->moduleUninstaller = $this->getMock(\Magento\Setup\Model\ModuleUninstaller::class, [], [], '', false); $this->moduleRegistryUninstaller = $this->getMock( - 'Magento\Setup\Model\ModuleRegistryUninstaller', + \Magento\Setup\Model\ModuleRegistryUninstaller::class, [], [], '', @@ -164,12 +178,12 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->moduleUninstaller, $this->moduleRegistryUninstaller ); - $this->question = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper', [], [], '', false); + $this->question = $this->getMock(\Symfony\Component\Console\Helper\QuestionHelper::class, [], [], '', false); $this->question ->expects($this->any()) ->method('ask') ->will($this->returnValue(true)); - $this->helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $this->helperSet = $this->getMock(\Symfony\Component\Console\Helper\HelperSet::class, [], [], '', false); $this->helperSet ->expects($this->any()) ->method('get') @@ -394,13 +408,13 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->setUpExecute(); $this->moduleUninstaller->expects($this->once()) ->method('uninstallCode') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDb') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->tester->execute($input); } @@ -410,13 +424,13 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->setUpExecute(); $this->moduleUninstaller->expects($this->once()) ->method('uninstallCode') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDb') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->cleanupFiles->expects($this->once())->method('clearMaterializedViewFiles'); $this->tester->execute($input); } @@ -427,16 +441,16 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->setUpExecute(); $this->moduleUninstaller->expects($this->once()) ->method('uninstallData') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleUninstaller->expects($this->once()) ->method('uninstallCode') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDb') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->tester->execute($input); } @@ -446,16 +460,16 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->setUpExecute(); $this->moduleUninstaller->expects($this->once()) ->method('uninstallData') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleUninstaller->expects($this->once()) ->method('uninstallCode') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDb') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->cleanupFiles->expects($this->once())->method('clearMaterializedViewFiles'); $this->tester->execute($input); } @@ -466,13 +480,13 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->setUpExecute(); $this->moduleUninstaller->expects($this->once()) ->method('uninstallCode') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDb') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->backupRollback->expects($this->once()) ->method('codeBackup') ->willReturn($this->backupRollback); @@ -485,13 +499,13 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->setUpExecute(); $this->moduleUninstaller->expects($this->once()) ->method('uninstallCode') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDb') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->backupRollback->expects($this->once()) ->method('codeBackup') ->willReturn($this->backupRollback); @@ -504,13 +518,13 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->setUpExecute(); $this->moduleUninstaller->expects($this->once()) ->method('uninstallCode') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDb') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->backupRollback->expects($this->once()) ->method('dbBackup') ->willReturn($this->backupRollback); @@ -523,13 +537,13 @@ class ModuleUninstallCommandTest extends \PHPUnit_Framework_TestCase $this->setUpExecute(); $this->moduleUninstaller->expects($this->once()) ->method('uninstallCode') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDb') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') - ->with($this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface'), $input['module']); + ->with($this->isInstanceOf(\Symfony\Component\Console\Output\OutputInterface::class), $input['module']); $this->question ->expects($this->once()) ->method('ask') diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php index ce36008d66afab83f44f5db02d42d0a0f8ade9b2..571c21d7c305534d9ebbcf2fa976e851da2ebd18 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php @@ -52,19 +52,19 @@ class RollbackCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false ); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); - $this->backupRollback = $this->getMock('Magento\Framework\Setup\BackupRollback', [], [], '', false); + $this->backupRollback = $this->getMock(\Magento\Framework\Setup\BackupRollback::class, [], [], '', false); $this->backupRollbackFactory = $this->getMock( - 'Magento\Framework\Setup\BackupRollbackFactory', + \Magento\Framework\Setup\BackupRollbackFactory::class, [], [], '', @@ -74,14 +74,14 @@ class RollbackCommandTest extends \PHPUnit_Framework_TestCase ->method('create') ->willReturn($this->backupRollback); $appState = $this->getMock( - 'Magento\Framework\App\State', + \Magento\Framework\App\State::class, [], [], '', false ); $configLoader = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManager\ConfigLoaderInterface', + \Magento\Framework\ObjectManager\ConfigLoaderInterface::class, [], '', false @@ -90,12 +90,12 @@ class RollbackCommandTest extends \PHPUnit_Framework_TestCase $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ - ['Magento\Framework\Setup\BackupRollbackFactory', $this->backupRollbackFactory], - ['Magento\Framework\App\State', $appState], - ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], + [\Magento\Framework\Setup\BackupRollbackFactory::class, $this->backupRollbackFactory], + [\Magento\Framework\App\State::class, $appState], + [\Magento\Framework\ObjectManager\ConfigLoaderInterface::class, $configLoader], ])); - $this->helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); - $this->question = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper', [], [], '', false); + $this->helperSet = $this->getMock(\Symfony\Component\Console\Helper\HelperSet::class, [], [], '', false); + $this->question = $this->getMock(\Symfony\Component\Console\Helper\QuestionHelper::class, [], [], '', false); $this->question ->expects($this->any()) ->method('ask') diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/UninstallCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/UninstallCommandTest.php index a3183950c8e59e80386c12da4c95e53d19d985be..fb9ba2ce7c647238fe38eb2f41f88479bbf6baa3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/UninstallCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/UninstallCommandTest.php @@ -30,8 +30,8 @@ class UninstallCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); - $this->installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); + $this->installerFactory = $this->getMock(\Magento\Setup\Model\InstallerFactory::class, [], [], '', false); + $this->installer = $this->getMock(\Magento\Setup\Model\Installer::class, [], [], '', false); $this->command = new UninstallCommand($this->installerFactory); } @@ -53,14 +53,14 @@ class UninstallCommandTest extends \PHPUnit_Framework_TestCase public function checkInteraction($answer) { - $question = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper', [], [], '', false); + $question = $this->getMock(\Symfony\Component\Console\Helper\QuestionHelper::class, [], [], '', false); $question ->expects($this->once()) ->method('ask') ->will($this->returnValue($answer)); /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ - $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet = $this->getMock(\Symfony\Component\Console\Helper\HelperSet::class, [], [], '', false); $helperSet ->expects($this->once()) ->method('get') diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php index 46ebded67b6ec3920ffc1cf4a7ed5f8533b80ae4..aea98290aa898f911519ffc5e1aee313a0966190 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php @@ -12,8 +12,8 @@ class UpgradeCommandTest extends \PHPUnit_Framework_TestCase { public function testExecute() { - $installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); - $installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); + $installerFactory = $this->getMock(\Magento\Setup\Model\InstallerFactory::class, [], [], '', false); + $installer = $this->getMock(\Magento\Setup\Model\Installer::class, [], [], '', false); $installer->expects($this->at(0))->method('updateModulesSequence'); $installer->expects($this->at(1))->method('installSchema'); $installer->expects($this->at(2))->method('installDataFixtures'); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/CommandListTest.php b/setup/src/Magento/Setup/Test/Unit/Console/CommandListTest.php index ba41ea73d77c4a02e907584e3fe17a5dc3296d27..ce13e6977e77371890d820f49aafded6d617a435 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/CommandListTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/CommandListTest.php @@ -22,7 +22,7 @@ class CommandListTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->serviceManager = $this->getMock('\Zend\ServiceManager\ServiceManager', [], [], '', false); + $this->serviceManager = $this->getMock(\Zend\ServiceManager\ServiceManager::class, [], [], '', false); $this->commandList = new CommandList($this->serviceManager); } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/CompilerPreparationTest.php b/setup/src/Magento/Setup/Test/Unit/Console/CompilerPreparationTest.php index ebf84062ee98023121772b280c26ae196f0b3985..9351010dbd00b4ba7f3713d97b54861af0fa971d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/CompilerPreparationTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/CompilerPreparationTest.php @@ -28,17 +28,17 @@ class CompilerPreparationTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->serviceManagerMock = $this->getMockBuilder('\Zend\ServiceManager\ServiceManager') + $this->serviceManagerMock = $this->getMockBuilder(\Zend\ServiceManager\ServiceManager::class) ->disableOriginalConstructor() ->getMock(); - $this->inputMock = $this->getMockBuilder('\Symfony\Component\Console\Input\ArgvInput') + $this->inputMock = $this->getMockBuilder(\Symfony\Component\Console\Input\ArgvInput::class) ->disableOriginalConstructor() ->getMock(); - $this->filesystemDriverMock = $this->getMockBuilder('\Magento\Framework\Filesystem\Driver\File') + $this->filesystemDriverMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Driver\File::class) ->disableOriginalConstructor() ->getMock(); $this->model = (new ObjectManager($this))->getObject( - '\Magento\Setup\Console\CompilerPreparation', + \Magento\Setup\Console\CompilerPreparation::class, [ 'serviceManager' => $this->serviceManagerMock, 'input' => $this->inputMock, diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/AddDatabaseTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/AddDatabaseTest.php index 512f882a0b8c58e02a7a662c2b2938c3f8843ff0..64c431d946ea2e9ac499f0b1dcac4bdc2d6b0ba7 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/AddDatabaseTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/AddDatabaseTest.php @@ -15,7 +15,7 @@ class AddDatabaseTest extends \PHPUnit_Framework_TestCase /** @var $controller AddDatabase */ $controller = new AddDatabase(); $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/BackupActionItemsTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/BackupActionItemsTest.php index 62b7a64ba0dff73872d50136dbeef55888ae1e25..a082542fb66ad7b1740346d147d8d5cdb22c5210 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/BackupActionItemsTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/BackupActionItemsTest.php @@ -9,6 +9,9 @@ namespace Magento\Setup\Test\Unit\Controller; use \Magento\Setup\Controller\BackupActionItems; use \Magento\Setup\Controller\ResponseTypeInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class BackupActionItemsTest extends \PHPUnit_Framework_TestCase { /** @@ -45,20 +48,22 @@ class BackupActionItemsTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); - $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $this->directoryList = + $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); + $this->objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $this->backupRollback = $this->getMock( - 'Magento\Setup\Model\BackupRollback', + \Magento\Setup\Model\BackupRollback::class, ['getDBDiskSpace', 'dbBackup'], [], '', false ); - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); $objectManager->expects($this->once())->method('create')->willReturn($this->backupRollback); $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); - $this->log = $this->getMock('Magento\Setup\Model\WebLogger', [], [], '', false); - $this->filesystem = $this->getMock('Magento\Framework\Backup\Filesystem', [], [], '', false); + $this->log = $this->getMock(\Magento\Setup\Model\WebLogger::class, [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Backup\Filesystem::class, [], [], '', false); $this->controller = new BackupActionItems( $this->objectManagerProvider, @@ -67,11 +72,11 @@ class BackupActionItemsTest extends \PHPUnit_Framework_TestCase $this->filesystem ); - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->any())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->any())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->any())->method('setTarget')->with($this->controller)->willReturn($mvcEvent); @@ -89,7 +94,7 @@ class BackupActionItemsTest extends \PHPUnit_Framework_TestCase $this->directoryList->expects($this->once())->method('getPath')->willReturn(__DIR__); $this->filesystem->expects($this->once())->method('validateAvailableDiscSpace'); $jsonModel = $this->controller->checkAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, $variables['responseType']); @@ -104,7 +109,7 @@ class BackupActionItemsTest extends \PHPUnit_Framework_TestCase $this->throwException(new \Exception("Test error message")) ); $jsonModel = $this->controller->checkAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_ERROR, $variables['responseType']); @@ -116,7 +121,7 @@ class BackupActionItemsTest extends \PHPUnit_Framework_TestCase { $this->backupRollback->expects($this->once())->method('dbBackup')->willReturn('backup/path/'); $jsonModel = $this->controller->createAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, $variables['responseType']); @@ -127,6 +132,6 @@ class BackupActionItemsTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $model = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $model); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $model); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/CompleteBackupTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/CompleteBackupTest.php index 4adf3fe1579f07edea3ae46fc1571e780f9975e6..7101629502cb26f3350e33da6d2082ff31ae6d55 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/CompleteBackupTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/CompleteBackupTest.php @@ -25,7 +25,7 @@ class CompleteBackupTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $this->assertSame('/magento/setup/complete-backup.phtml', $viewModel->getTemplate()); } @@ -33,7 +33,7 @@ class CompleteBackupTest extends \PHPUnit_Framework_TestCase public function testProgressAction() { $viewModel = $this->controller->progressAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $this->assertSame('/magento/setup/complete-backup/progress.phtml', $viewModel->getTemplate()); } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ComponentGridTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ComponentGridTest.php index 9d56a19426e0538125cb810ceacf70fc259304fe..380a0615dae07c3dd70146a02d3081d390dbf57a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ComponentGridTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ComponentGridTest.php @@ -18,6 +18,9 @@ use Magento\Framework\Module\ModuleList; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Setup\Model\MarketplaceManager; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ComponentGridTest extends \PHPUnit_Framework_TestCase { /** @@ -100,7 +103,6 @@ class ComponentGridTest extends \PHPUnit_Framework_TestCase 'time' => self::FORMATTED_TIME, ], ]; - $this->lastSyncData = [ "lastSyncDate" => "1447271496", "packages" => [ @@ -129,42 +131,60 @@ class ComponentGridTest extends \PHPUnit_Framework_TestCase ]; $allComponentData = array_merge($allComponentData, $this->componentData); $this->composerInformationMock = $this->getMock( - 'Magento\Framework\Composer\ComposerInformation', + \Magento\Framework\Composer\ComposerInformation::class, [], [], '', false ); /** @var ObjectManagerProvider|\PHPUnit_Framework_MockObject_MockObject $objectManagerProvider */ - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); - $objectManagerProvider->expects($this->once()) - ->method('get') - ->willReturn($objectManager); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); $this->packageInfoFactoryMock = $this - ->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); - $this->enabledModuleListMock = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); + ->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false); + $this->enabledModuleListMock = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); $this->enabledModuleListMock->expects($this->any())->method('has')->willReturn(true); - $this->fullModuleListMock = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); + $this->fullModuleListMock = $this->getMock(\Magento\Framework\Module\FullModuleList::class, [], [], '', false); $this->fullModuleListMock->expects($this->any())->method('getNames')->willReturn($allComponentData); - $this->timezoneMock = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface', [], [], '', false); - $objectManager->expects($this->any()) - ->method('get') + $this->timezoneMock = $this->getMock( + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, + [], + [], + '', + false + ); + $objectManager->expects($this->any())->method('get') ->willReturnMap([ - ['Magento\Framework\Module\PackageInfoFactory', $this->packageInfoFactoryMock], - ['Magento\Framework\Module\FullModuleList', $this->fullModuleListMock], - ['Magento\Framework\Module\ModuleList', $this->enabledModuleListMock], - ['Magento\Framework\Stdlib\DateTime\TimezoneInterface', $this->timezoneMock] + [\Magento\Framework\Module\PackageInfoFactory::class, $this->packageInfoFactoryMock], + [\Magento\Framework\Module\FullModuleList::class, $this->fullModuleListMock], + [\Magento\Framework\Module\ModuleList::class, $this->enabledModuleListMock], + [\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, $this->timezoneMock] ]); - /** @var TimezoneProvider|\PHPUnit_Framework_MockObject_MockObject $timezoneProviderMock */ - $timezoneProviderMock = $this->getMock('\Magento\Setup\Model\DateTime\TimezoneProvider', [], [], '', false); - $timezoneProviderMock->expects($this->any()) - ->method('get') - ->willReturn($this->timezoneMock); - $this->packageInfo = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); - $this->updatePackagesCacheMock = $this->getMock('Magento\Setup\Model\UpdatePackagesCache', [], [], '', false); - $this->marketplaceManagerMock = $this->getMock('Magento\Setup\Model\MarketplaceManager', [], [], '', false); + $timezoneProviderMock = $this->getMock( + \Magento\Setup\Model\DateTime\TimezoneProvider::class, + [], + [], + '', + false + ); + $timezoneProviderMock->expects($this->any())->method('get')->willReturn($this->timezoneMock); + $this->packageInfo = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); + $this->updatePackagesCacheMock = $this->getMock( + \Magento\Setup\Model\UpdatePackagesCache::class, + [], + [], + '', + false + ); + $this->marketplaceManagerMock = $this->getMock( + \Magento\Setup\Model\MarketplaceManager::class, + [], + [], + '', + false + ); $this->packageInfoFactoryMock->expects($this->once())->method('create')->willReturn($this->packageInfo); $this->controller = new ComponentGrid( $this->composerInformationMock, @@ -178,7 +198,7 @@ class ComponentGridTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } @@ -210,7 +230,7 @@ class ComponentGridTest extends \PHPUnit_Framework_TestCase ->willReturn($this->lastSyncData); $this->setupTimezoneMock(); $jsonModel = $this->controller->componentsAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertTrue($variables['success']); @@ -241,7 +261,7 @@ class ComponentGridTest extends \PHPUnit_Framework_TestCase ->willReturn($this->lastSyncData); $this->setupTimezoneMock(); $jsonModel = $this->controller->syncAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertTrue($variables['success']); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/CreateAdminAccountTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/CreateAdminAccountTest.php index cc7a78514cd545b0b2bbfb8ce9d0add778b29da5..5fcd7038fc6b5de0c4af73e09240ca4591e18590 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/CreateAdminAccountTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/CreateAdminAccountTest.php @@ -14,7 +14,7 @@ class CreateAdminAccountTest extends \PHPUnit_Framework_TestCase { $controller = new CreateAdminAccount(); $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/CreateBackupTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/CreateBackupTest.php index 8cbc237ccebe1f137452ac3cb1b80cc521efbd35..fae0ea32637eafc7f1189f00cd54265e6f32533a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/CreateBackupTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/CreateBackupTest.php @@ -15,7 +15,7 @@ class CreateBackupTest extends \PHPUnit_Framework_TestCase /** @var $controller CreateBackup */ $controller = new CreateBackup(); $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/CustomizeYourStoreTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/CustomizeYourStoreTest.php index 098ab491a2e66ef18a5090156e69fb6e03820705..4fd150af9cbcef7b1bafe5091781e1b92a8815a8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/CustomizeYourStoreTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/CustomizeYourStoreTest.php @@ -37,18 +37,18 @@ class CustomizeYourStoreTest extends \PHPUnit_Framework_TestCase public function setup() { - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $this->objectManager = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $this->objectManager = $this->getMock(\Magento\Framework\App\ObjectManager::class, [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); $this->sampleDataState = $this->getMock( - 'Magento\Framework\Setup\SampleData\State', + \Magento\Framework\Setup\SampleData\State::class, [], [], '', false ); - $this->lists = $this->getMock('\Magento\Framework\Setup\Lists', [], [], '', false); - $this->moduleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); + $this->lists = $this->getMock(\Magento\Framework\Setup\Lists::class, [], [], '', false); + $this->moduleList = $this->getMock(\Magento\Framework\Module\FullModuleList::class, [], [], '', false); $this->controller = new CustomizeYourStore($this->moduleList, $this->lists, $objectManagerProvider); } @@ -77,7 +77,7 @@ class CustomizeYourStoreTest extends \PHPUnit_Framework_TestCase $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $variables = $viewModel->getVariables(); @@ -115,7 +115,7 @@ class CustomizeYourStoreTest extends \PHPUnit_Framework_TestCase public function testDefaultTimeZoneAction() { $jsonModel = $this->controller->defaultTimeZoneAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $this->assertArrayHasKey('defaultTimeZone', $jsonModel->getVariables()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/DataOptionTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/DataOptionTest.php index 08d2f435edb8db03220d2e76833c4f00389081de..22176845d79a716b85d3704a168656fafe3c2dbe 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/DataOptionTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/DataOptionTest.php @@ -37,14 +37,14 @@ class DataOptionTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $this->response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $this->request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $this->response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $this->uninstallCollector = $this->getMock('Magento\Setup\Model\UninstallCollector', [], [], '', false); + $this->uninstallCollector = $this->getMock(\Magento\Setup\Model\UninstallCollector::class, [], [], '', false); $this->controller = new DataOption($this->uninstallCollector); - $this->mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $this->mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $this->mvcEvent->expects($this->any()) ->method('setRequest') ->with($this->request) @@ -63,7 +63,7 @@ class DataOptionTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('\Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } @@ -75,6 +75,7 @@ class DataOptionTest extends \PHPUnit_Framework_TestCase $this->uninstallCollector->expects($this->never())->method('collectUninstall')->with(["some_module"]); $this->assertFalse($this->controller->hasUninstallAction()->getVariable("hasUninstall")); } + /** * @param string $content * @param array $expected diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php index 5509808523dbb1aedc99e25557faf41e0f757685..693ad27f17081f8c65080526b508e7dce69ae38c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php @@ -11,6 +11,9 @@ use Magento\Setup\Controller\ReadinessCheckUpdater; use Magento\Setup\Controller\ResponseTypeInterface; use Zend\View\Model\JsonModel; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class EnvironmentTest extends \PHPUnit_Framework_TestCase { /** @@ -40,16 +43,16 @@ class EnvironmentTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->permissions = $this->getMock('Magento\Framework\Setup\FilePermissions', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->permissions = $this->getMock(\Magento\Framework\Setup\FilePermissions::class, [], [], '', false); $this->cronScriptReadinessCheck = $this->getMock( - 'Magento\Setup\Model\CronScriptReadinessCheck', + \Magento\Setup\Model\CronScriptReadinessCheck::class, [], [], '', false ); - $this->phpReadinessCheck = $this->getMock('Magento\Setup\Model\PhpReadinessCheck', [], [], '', false); + $this->phpReadinessCheck = $this->getMock(\Magento\Setup\Model\PhpReadinessCheck::class, [], [], '', false); $this->environment = new Environment( $this->permissions, $this->filesystem, @@ -60,11 +63,11 @@ class EnvironmentTest extends \PHPUnit_Framework_TestCase public function testPhpVersionActionInstaller() { - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent); @@ -78,18 +81,19 @@ class EnvironmentTest extends \PHPUnit_Framework_TestCase public function testPhpVersionActionUpdater() { - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent); $mvcEvent->expects($this->any())->method('getRouteMatch')->willReturn($routeMatch); $request->expects($this->once())->method('getQuery')->willReturn(ReadinessCheckUpdater::UPDATER); $this->phpReadinessCheck->expects($this->never())->method('checkPhpVersion'); - $read = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface', [], '', false); + $read = + $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class, [], '', false); $this->filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($read); $read->expects($this->once()) ->method('readFile') @@ -101,11 +105,11 @@ class EnvironmentTest extends \PHPUnit_Framework_TestCase public function testPhpSettingsActionInstaller() { - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent); @@ -119,18 +123,19 @@ class EnvironmentTest extends \PHPUnit_Framework_TestCase public function testPhpSettingsActionUpdater() { - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent); $mvcEvent->expects($this->any())->method('getRouteMatch')->willReturn($routeMatch); $request->expects($this->once())->method('getQuery')->willReturn(ReadinessCheckUpdater::UPDATER); $this->phpReadinessCheck->expects($this->never())->method('checkPhpSettings'); - $read = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface', [], '', false); + $read = + $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class, [], '', false); $this->filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($read); $read->expects($this->once()) ->method('readFile') @@ -142,11 +147,11 @@ class EnvironmentTest extends \PHPUnit_Framework_TestCase public function testPhpExtensionsActionInstaller() { - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent); @@ -160,18 +165,19 @@ class EnvironmentTest extends \PHPUnit_Framework_TestCase public function testPhpExtensionsActionUpdater() { - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent); $mvcEvent->expects($this->any())->method('getRouteMatch')->willReturn($routeMatch); $request->expects($this->once())->method('getQuery')->willReturn(ReadinessCheckUpdater::UPDATER); $this->phpReadinessCheck->expects($this->never())->method('checkPhpExtensions'); - $read = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface', [], '', false); + $read = + $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\ReadInterface::class, [], '', false); $this->filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($read); $read->expects($this->once()) ->method('readFile') @@ -293,6 +299,6 @@ class EnvironmentTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $model = $this->environment->indexAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $model); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $model); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php index 0aa0daa6576fa2cfd67b07fbb6e3cc8ca2411f2d..21ff33c26b23b3aa3dcd667f493a31714cd21bdd 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php @@ -15,7 +15,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase /** @var $controller Index */ $controller = new Index(); $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertFalse($viewModel->terminate()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/InstallExtensionGridTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/InstallExtensionGridTest.php index b640a5db7c7d302a9dc0443050e2b0c31850e70a..4e422f6f576b1a1ab70450199e87f517638dc600 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/InstallExtensionGridTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/InstallExtensionGridTest.php @@ -25,7 +25,7 @@ class InstallExtensionGridTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->marketplaceManager = - $this->getMock('Magento\Setup\Model\MarketplaceManager', ['getPackagesForInstall'], [], '', false); + $this->getMock(\Magento\Setup\Model\MarketplaceManager::class, ['getPackagesForInstall'], [], '', false); $this->controller = new InstallExtensionGrid($this->marketplaceManager); } @@ -35,7 +35,7 @@ class InstallExtensionGridTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('\Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); } /** @@ -50,7 +50,7 @@ class InstallExtensionGridTest extends \PHPUnit_Framework_TestCase ->method('getPackagesForInstall') ->will($this->returnValue($extensions)); $jsonModel = $this->controller->extensionsAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('extensions', $variables); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php index b2ec9a6f86300f0b680ce37f9efc5e71c8a57a35..d0771b0cebaefe87ded260bdf93e36724534bb88 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/InstallTest.php @@ -8,6 +8,9 @@ namespace Magento\Setup\Test\Unit\Controller; use \Magento\Setup\Controller\Install; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class InstallTest extends \PHPUnit_Framework_TestCase { /** @@ -37,11 +40,12 @@ class InstallTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->webLogger = $this->getMock('\Magento\Setup\Model\WebLogger', [], [], '', false); - $installerFactory = $this->getMock('\Magento\Setup\Model\InstallerFactory', [], [], '', false); - $this->installer = $this->getMock('\Magento\Setup\Model\Installer', [], [], '', false); - $this->progressFactory = $this->getMock('\Magento\Setup\Model\Installer\ProgressFactory', [], [], '', false); - $this->sampleDataState = $this->getMock('\Magento\Framework\Setup\SampleData\State', [], [], '', false); + $this->webLogger = $this->getMock(\Magento\Setup\Model\WebLogger::class, [], [], '', false); + $installerFactory = $this->getMock(\Magento\Setup\Model\InstallerFactory::class, [], [], '', false); + $this->installer = $this->getMock(\Magento\Setup\Model\Installer::class, [], [], '', false); + $this->progressFactory = + $this->getMock(\Magento\Setup\Model\Installer\ProgressFactory::class, [], [], '', false); + $this->sampleDataState = $this->getMock(\Magento\Framework\Setup\SampleData\State::class, [], [], '', false); $installerFactory->expects($this->once())->method('create')->with($this->webLogger) ->willReturn($this->installer); @@ -56,7 +60,7 @@ class InstallTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('\Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } @@ -66,7 +70,7 @@ class InstallTest extends \PHPUnit_Framework_TestCase $this->installer->expects($this->once())->method('install'); $this->installer->expects($this->exactly(2))->method('getInstallInfo'); $jsonModel = $this->controller->startAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('key', $variables); $this->assertArrayHasKey('success', $variables); @@ -90,7 +94,7 @@ class InstallTest extends \PHPUnit_Framework_TestCase $this->installer->method('install'); $this->sampleDataState->expects($this->once())->method('hasError')->willReturn(true); $jsonModel = $this->controller->startAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertTrue($variables['success']); @@ -103,13 +107,13 @@ class InstallTest extends \PHPUnit_Framework_TestCase $consoleMessages = ['key1' => 'log message 1', 'key2' => 'log message 2']; $this->webLogger->expects($this->once())->method('logfileExists')->willReturn(true); - $progress = $this->getMock('\Magento\Setup\Model\Installer\Progress', [], [], '', false); + $progress = $this->getMock(\Magento\Setup\Model\Installer\Progress::class, [], [], '', false); $this->progressFactory->expects($this->once())->method('createFromLog')->with($this->webLogger) ->willReturn($progress); $progress->expects($this->once())->method('getRatio')->willReturn($numValue); $this->webLogger->expects($this->once())->method('get')->willReturn($consoleMessages); $jsonModel = $this->controller->progressAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('progress', $variables); $this->assertArrayHasKey('success', $variables); @@ -126,7 +130,7 @@ class InstallTest extends \PHPUnit_Framework_TestCase $this->progressFactory->expects($this->once())->method('createFromLog') ->will($this->throwException(new \LogicException($e))); $jsonModel = $this->controller->progressAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('console', $variables); @@ -139,12 +143,12 @@ class InstallTest extends \PHPUnit_Framework_TestCase { $numValue = 42; $this->webLogger->expects($this->once())->method('logfileExists')->willReturn(true); - $progress = $this->getMock('\Magento\Setup\Model\Installer\Progress', [], [], '', false); + $progress = $this->getMock(\Magento\Setup\Model\Installer\Progress::class, [], [], '', false); $progress->expects($this->once())->method('getRatio')->willReturn($numValue); $this->progressFactory->expects($this->once())->method('createFromLog')->willReturn($progress); $this->sampleDataState->expects($this->once())->method('hasError')->willReturn(true); $jsonModel = $this->controller->progressAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('console', $variables); @@ -157,7 +161,7 @@ class InstallTest extends \PHPUnit_Framework_TestCase { $this->webLogger->expects($this->once())->method('logfileExists')->willReturn(false); $jsonModel = $this->controller->progressAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('console', $variables); @@ -168,11 +172,11 @@ class InstallTest extends \PHPUnit_Framework_TestCase public function testDispatch() { - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setTarget')->with($this->controller)->willReturn($mvcEvent); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/LandingInstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/LandingInstallerTest.php index ac14f325fe59b944322b4067ac6637d8eb8f8bff..ad6a65c0c82337dd74c6d6a35cf9e9d31747544a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/LandingInstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/LandingInstallerTest.php @@ -21,7 +21,7 @@ class LandingInstallerTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { /** @var \Magento\Framework\App\ProductMetadata|\PHPUnit_Framework_MockObject_MockObject $productMetadataMock */ - $productMetadataMock = $this->getMockBuilder('Magento\Framework\App\ProductMetadata') + $productMetadataMock = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class) ->setMethods(['getVersion']) ->disableOriginalConstructor() ->getMock(); @@ -32,7 +32,7 @@ class LandingInstallerTest extends \PHPUnit_Framework_TestCase $controller = new LandingInstaller($productMetadataMock); $_SERVER['DOCUMENT_ROOT'] = 'some/doc/root/value'; $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $this->assertEquals('/magento/setup/landing.phtml', $viewModel->getTemplate()); $variables = $viewModel->getVariables(); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/LandingUpdaterTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/LandingUpdaterTest.php index 7960ecf8c6af1bbab785a168f97c1c23d398b298..303f0a363a381f4e2abc1480ca854c0beff9b4e0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/LandingUpdaterTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/LandingUpdaterTest.php @@ -21,7 +21,7 @@ class LandingUpdaterTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { /** @var \Magento\Framework\App\ProductMetadata|\PHPUnit_Framework_MockObject_MockObject $productMetadataMock */ - $productMetadataMock = $this->getMockBuilder('Magento\Framework\App\ProductMetadata') + $productMetadataMock = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class) ->setMethods(['getVersion']) ->disableOriginalConstructor() ->getMock(); @@ -32,7 +32,7 @@ class LandingUpdaterTest extends \PHPUnit_Framework_TestCase $controller = new LandingUpdater($productMetadataMock); $_SERVER['DOCUMENT_ROOT'] = 'some/doc/root/value'; $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $this->assertEquals('/magento/setup/landing.phtml', $viewModel->getTemplate()); $variables = $viewModel->getVariables(); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/LicenseTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/LicenseTest.php index 9c59ec957b9691a80c2a1ed90e07230dc45cd581..73c0680342af61d772c4e6302cd475af45d2045d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/LicenseTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/LicenseTest.php @@ -22,7 +22,7 @@ class LicenseTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->licenseModel = $this->getMock('\Magento\Setup\Model\License', [], [], '', false); + $this->licenseModel = $this->getMock(\Magento\Setup\Model\License::class, [], [], '', false); $this->controller = new License($this->licenseModel); } @@ -30,7 +30,7 @@ class LicenseTest extends \PHPUnit_Framework_TestCase { $this->licenseModel->expects($this->once())->method('getContents')->willReturn('some license string'); $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertArrayHasKey('license', $viewModel->getVariables()); } @@ -38,7 +38,7 @@ class LicenseTest extends \PHPUnit_Framework_TestCase { $this->licenseModel->expects($this->once())->method('getContents')->willReturn(false); $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertArrayHasKey('message', $viewModel->getVariables()); $this->assertEquals('error/404', $viewModel->getTemplate()); } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/MaintenanceTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/MaintenanceTest.php index 955734accde2375a7604d0ad6ced492eff1fc5d3..864e84e1a949e2b94c854fa7f080c4e75cb7316c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/MaintenanceTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/MaintenanceTest.php @@ -26,14 +26,14 @@ class MaintenanceTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); + $this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); $this->controller = new Maintenance($this->maintenanceMode); - $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); + $request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); - $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $mvcEvent->expects($this->any())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->any())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->any())->method('setTarget')->with($this->controller)->willReturn($mvcEvent); @@ -49,7 +49,7 @@ class MaintenanceTest extends \PHPUnit_Framework_TestCase { $this->maintenanceMode->expects($this->once())->method('set'); $jsonModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, $variables['responseType']); @@ -61,7 +61,7 @@ class MaintenanceTest extends \PHPUnit_Framework_TestCase $this->throwException(new \Exception("Test error message")) ); $jsonModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_ERROR, $variables['responseType']); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php index 9b9d49cd392e01953bef961687fe99b704033731..d0219fe7420a9be668c042fbf851686e2c6432f9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php @@ -30,8 +30,8 @@ class MarketplaceTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->composerInformation = - $this->getMock('Magento\Framework\Composer\ComposerInformation', [], [], '', false); - $this->marketplaceManager = $this->getMock('Magento\Setup\Model\MarketplaceManager', [], [], '', false); + $this->getMock(\Magento\Framework\Composer\ComposerInformation::class, [], [], '', false); + $this->marketplaceManager = $this->getMock(\Magento\Setup\Model\MarketplaceManager::class, [], [], '', false); $this->controller = new Marketplace($this->composerInformation, $this->marketplaceManager); } @@ -49,7 +49,7 @@ class MarketplaceTest extends \PHPUnit_Framework_TestCase ->method('saveAuthJson') ->willReturn(true); $jsonModel = $this->controller->saveAuthJsonAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertTrue($variables['success']); @@ -68,7 +68,7 @@ class MarketplaceTest extends \PHPUnit_Framework_TestCase ->expects($this->never()) ->method('saveAuthJson'); $jsonModel = $this->controller->saveAuthJsonAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('message', $variables); @@ -89,7 +89,7 @@ class MarketplaceTest extends \PHPUnit_Framework_TestCase ->method('checkCredentialsAction') ->will($this->returnValue(\Zend_Json::encode(['success' => true]))); $jsonModel = $this->controller->checkAuthAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertTrue($variables['success']); @@ -105,7 +105,7 @@ class MarketplaceTest extends \PHPUnit_Framework_TestCase ->method('getAuthJsonData') ->will($this->throwException(new \Exception)); $jsonModel = $this->controller->checkAuthAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('message', $variables); @@ -123,7 +123,7 @@ class MarketplaceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $jsonModel = $this->controller->removeCredentialsAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertTrue($variables['success']); @@ -139,7 +139,7 @@ class MarketplaceTest extends \PHPUnit_Framework_TestCase ->method('removeCredentials') ->will($this->throwException(new \Exception)); $jsonModel = $this->controller->removeCredentialsAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('message', $variables); @@ -152,13 +152,13 @@ class MarketplaceTest extends \PHPUnit_Framework_TestCase public function testPopupAuthAction() { $viewModel = $this->controller->popupAuthAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } public function testIndexAction() { $model = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $model); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $model); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ModulesTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ModulesTest.php index 3b7260f1717f7063e6aa155240af9083c625ae71..efde9686db353b7073b6cc8011b8b971b20e5731 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ModulesTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ModulesTest.php @@ -34,14 +34,14 @@ class ModulesTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $this->objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); /** @var * $objectManagerProvider \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\ObjectManagerProvider */ - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager); - $this->modules = $this->getMock('Magento\Setup\Model\ModuleStatus', [], [], '', false); - $this->status = $this->getMock('Magento\Framework\Module\Status', [], [], '', false); + $this->modules = $this->getMock(\Magento\Setup\Model\ModuleStatus::class, [], [], '', false); + $this->status = $this->getMock(\Magento\Framework\Module\Status::class, [], [], '', false); $this->objectManager->expects($this->once())->method('create')->will($this->returnValue($this->status)); $this->controller = new Modules($this->modules, $objectManagerProvider); } @@ -56,7 +56,7 @@ class ModulesTest extends \PHPUnit_Framework_TestCase $this->modules->expects($this->once())->method('getAllModules')->willReturn($expected['modules']); $this->status->expects($this->once())->method('checkConstraints')->willReturn([]); $jsonModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertTrue($variables['success']); @@ -74,7 +74,7 @@ class ModulesTest extends \PHPUnit_Framework_TestCase ->method('checkConstraints') ->willReturn(['ModuleA', 'ModuleB']); $jsonModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('error', $variables); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/NavigationTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/NavigationTest.php index 39ce3c81711b8821bb308a66d1f5b834b53229a9..c50e27c74af6cf48a702acea1cb6c14f8f575f00 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/NavigationTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/NavigationTest.php @@ -34,9 +34,10 @@ class NavigationTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->navigationModel = $this->getMock('\Magento\Setup\Model\Navigation', [], [], '', false); - $this->status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); - $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $this->navigationModel = $this->getMock(\Magento\Setup\Model\Navigation::class, [], [], '', false); + $this->status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); + $this->objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $this->controller = new Navigation($this->navigationModel, $this->status, $this->objectManagerProvider); } @@ -45,14 +46,14 @@ class NavigationTest extends \PHPUnit_Framework_TestCase $this->navigationModel->expects($this->once())->method('getData')->willReturn('some data'); $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('\Zend\View\Model\JsonModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $viewModel); $this->assertArrayHasKey('nav', $viewModel->getVariables()); } public function testMenuActionUpdater() { $viewModel = $this->controller->menuAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $variables = $viewModel->getVariables(); $this->assertArrayHasKey('menu', $variables); $this->assertArrayHasKey('main', $variables); @@ -63,7 +64,7 @@ class NavigationTest extends \PHPUnit_Framework_TestCase public function testMenuActionInstaller() { $viewModel = $this->controller->menuAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $variables = $viewModel->getVariables(); $this->assertArrayHasKey('menu', $variables); $this->assertArrayHasKey('main', $variables); @@ -75,7 +76,7 @@ class NavigationTest extends \PHPUnit_Framework_TestCase { $this->navigationModel->expects($this->once())->method('getType')->willReturn(NavModel::NAV_INSTALLER); $viewModel = $this->controller->headerBarAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $variables = $viewModel->getVariables(); $this->assertArrayHasKey('menu', $variables); $this->assertArrayHasKey('main', $variables); @@ -87,7 +88,7 @@ class NavigationTest extends \PHPUnit_Framework_TestCase { $this->navigationModel->expects($this->once())->method('getType')->willReturn(NavModel::NAV_UPDATER); $viewModel = $this->controller->headerBarAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $variables = $viewModel->getVariables(); $this->assertArrayHasKey('menu', $variables); $this->assertArrayHasKey('main', $variables); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/OtherComponentsGridTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/OtherComponentsGridTest.php index 0c10405da45bb6119ec6a250c6d6afeb36336768..bc5af72b0cb23091ebacc48bfa7e8afcabf0fe16 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/OtherComponentsGridTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/OtherComponentsGridTest.php @@ -32,15 +32,15 @@ class OtherComponentsGridTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->composerInformation = $this->getMock( - 'Magento\Framework\Composer\ComposerInformation', + \Magento\Framework\Composer\ComposerInformation::class, [], [], '', false ); - $this->infoCommand = $this->getMock('Magento\Composer\InfoCommand', [], [], '', false); + $this->infoCommand = $this->getMock(\Magento\Composer\InfoCommand::class, [], [], '', false); $magentoComposerApplicationFactory = $this->getMock( - 'Magento\Framework\Composer\MagentoComposerApplicationFactory', + \Magento\Framework\Composer\MagentoComposerApplicationFactory::class, [], [], '', @@ -80,7 +80,7 @@ class OtherComponentsGridTest extends \PHPUnit_Framework_TestCase ] ]); $jsonModel = $this->controller->componentsAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, $variables['responseType']); @@ -120,7 +120,7 @@ class OtherComponentsGridTest extends \PHPUnit_Framework_TestCase ->method('getInstalledMagentoPackages') ->will($this->throwException(new \Exception("Test error message"))); $jsonModel = $this->controller->componentsAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_ERROR, $variables['responseType']); @@ -129,6 +129,6 @@ class OtherComponentsGridTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $model = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $model); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $model); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ReadinessCheckInstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ReadinessCheckInstallerTest.php index c2e019d6d7423dedea1602726fc66ebd07707bf0..e60c494077318ca2c48879c40108a7ed96551c1a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ReadinessCheckInstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ReadinessCheckInstallerTest.php @@ -23,7 +23,7 @@ class ReadinessCheckInstallerTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $variables = $viewModel->getVariables(); $this->assertArrayHasKey('actionFrom', $variables); @@ -33,7 +33,7 @@ class ReadinessCheckInstallerTest extends \PHPUnit_Framework_TestCase public function testProgressAction() { $viewModel = $this->controller->progressAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $this->assertSame('/magento/setup/readiness-check/progress.phtml', $viewModel->getTemplate()); } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ReadinessCheckUpdaterTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ReadinessCheckUpdaterTest.php index 3dbf892128b9e27e87736008d90bb7352de3c6f7..0a67407aad61969ad0094840ddd3a18e31438bd2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ReadinessCheckUpdaterTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ReadinessCheckUpdaterTest.php @@ -23,7 +23,7 @@ class ReadinessCheckUpdaterTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $variables = $viewModel->getVariables(); $this->assertArrayHasKey('actionFrom', $variables); @@ -33,7 +33,7 @@ class ReadinessCheckUpdaterTest extends \PHPUnit_Framework_TestCase public function testProgressAction() { $viewModel = $this->controller->progressAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $this->assertSame('/magento/setup/readiness-check/progress.phtml', $viewModel->getTemplate()); } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/SelectVersionTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/SelectVersionTest.php index 3127dd297e4885e037198b116943658779243595..50aebec46e3b2cba985ff2f9d850f99de2cd3901 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/SelectVersionTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/SelectVersionTest.php @@ -25,7 +25,7 @@ class SelectVersionTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->systemPackage = $this->getMock('Magento\Setup\Model\SystemPackage', [], [], '', false); + $this->systemPackage = $this->getMock(\Magento\Setup\Model\SystemPackage::class, [], [], '', false); $this->controller = new SelectVersion( $this->systemPackage ); @@ -34,7 +34,7 @@ class SelectVersionTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } @@ -50,7 +50,7 @@ class SelectVersionTest extends \PHPUnit_Framework_TestCase ] ]); $jsonModel = $this->controller->systemPackageAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, $variables['responseType']); @@ -62,7 +62,7 @@ class SelectVersionTest extends \PHPUnit_Framework_TestCase ->method('getPackageVersions') ->will($this->throwException(new \Exception("Test error message"))); $jsonModel = $this->controller->systemPackageAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_ERROR, $variables['responseType']); @@ -80,7 +80,7 @@ class SelectVersionTest extends \PHPUnit_Framework_TestCase ] ]); $jsonModel = $this->controller->installedSystemPackageAction(); - $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, $variables['responseType']); diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php index bb826dda5e1234b64ac5bb02fdeadfe02d83ebec..a58c9edbd44d3381e2938b73b272ec4db9486a60 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php @@ -27,11 +27,13 @@ class SessionTest extends \PHPUnit_Framework_TestCase public function setUp() { - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', ['get'], [], '', false); + $objectManager = + $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class, [], '', false); + $objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, ['get'], [], '', false); $this->objectManager = $objectManager; $this->objectManagerProvider = $objectManagerProvider; - $this->serviceManager = $this->getMock('Zend\ServiceManager\ServiceManager', ['get'], [], '', false); + $this->serviceManager = $this->getMock(\Zend\ServiceManager\ServiceManager::class, ['get'], [], '', false); } /** @@ -42,21 +44,22 @@ class SessionTest extends \PHPUnit_Framework_TestCase $this->objectManagerProvider->expects($this->once())->method('get')->will( $this->returnValue($this->objectManager) ); - $deployConfigMock = $this->getMock('Magento\Framework\App\DeploymentConfig', ['isAvailable'], [], '', false); + $deployConfigMock = + $this->getMock(\Magento\Framework\App\DeploymentConfig::class, ['isAvailable'], [], '', false); $deployConfigMock->expects($this->once())->method('isAvailable')->will($this->returnValue(true)); - $stateMock = $this->getMock('Magento\Framework\App\State', ['setAreaCode'], [], '', false); + $stateMock = $this->getMock(\Magento\Framework\App\State::class, ['setAreaCode'], [], '', false); $stateMock->expects($this->once())->method('setAreaCode'); $sessionConfigMock = - $this->getMock('Magento\Backend\Model\Session\AdminConfig', ['setCookiePath'], [], '', false); + $this->getMock(\Magento\Backend\Model\Session\AdminConfig::class, ['setCookiePath'], [], '', false); $sessionConfigMock->expects($this->once())->method('setCookiePath'); - $urlMock = $this->getMock('\Magento\Backend\Model\Url', [], [], '', false); + $urlMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); $returnValueMap = [ - ['Magento\Framework\App\State', $stateMock], - ['Magento\Backend\Model\Session\AdminConfig', $sessionConfigMock], - ['Magento\Backend\Model\Url', $urlMock] + [\Magento\Framework\App\State::class, $stateMock], + [\Magento\Backend\Model\Session\AdminConfig::class, $sessionConfigMock], + [\Magento\Backend\Model\Url::class, $urlMock] ]; $this->serviceManager->expects($this->once())->method('get')->will($this->returnValue($deployConfigMock)); @@ -65,7 +68,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase ->method('get') ->will($this->returnValueMap($returnValueMap)); - $sessionMock = $this->getMock('Magento\Backend\Model\Auth\Session', ['prolong'], [], '', false); + $sessionMock = $this->getMock(\Magento\Backend\Model\Auth\Session::class, ['prolong'], [], '', false); $this->objectManager->expects($this->once()) ->method('create') ->will($this->returnValue($sessionMock)); @@ -82,6 +85,6 @@ class SessionTest extends \PHPUnit_Framework_TestCase /** @var $controller Session */ $controller = new Session($this->serviceManager, $this->objectManagerProvider); $viewModel = $controller->unloginAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php index c07ebd79e53e9143a0c9dee9fbd6965e89db1f3c..4399dd4a0c21c24d027b2bf2444b94b98b6564c2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php @@ -9,6 +9,10 @@ namespace Magento\Setup\Test\Unit\Controller; use Magento\Setup\Model\Navigation; use Magento\Setup\Controller\StartUpdater; +/** + * Class StartUpdaterTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class StartUpdaterTest extends \PHPUnit_Framework_TestCase { /** @@ -53,10 +57,10 @@ class StartUpdaterTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->updater = $this->getMock('Magento\Setup\Model\Updater', [], [], '', false); - $this->fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->navigation = $this->getMock('Magento\Setup\Model\Navigation', [], [], '', false); + $this->updater = $this->getMock(\Magento\Setup\Model\Updater::class, [], [], '', false); + $this->fullModuleList = $this->getMock(\Magento\Framework\Module\FullModuleList::class, [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->navigation = $this->getMock(\Magento\Setup\Model\Navigation::class, [], [], '', false); $this->controller = new StartUpdater( $this->filesystem, $this->navigation, @@ -71,10 +75,10 @@ class StartUpdaterTest extends \PHPUnit_Framework_TestCase ['title' => 'C', 'type' => 'enable'], ['title' => 'D', 'type' => 'disable'], ]); - $this->request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false); - $this->response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false); - $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false); - $this->mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false); + $this->request = $this->getMock(\Zend\Http\PhpEnvironment\Request::class, [], [], '', false); + $this->response = $this->getMock(\Zend\Http\PhpEnvironment\Response::class, [], [], '', false); + $routeMatch = $this->getMock(\Zend\Mvc\Router\RouteMatch::class, [], [], '', false); + $this->mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class, [], [], '', false); $this->mvcEvent->expects($this->any()) ->method('setRequest') ->with($this->request) @@ -93,7 +97,7 @@ class StartUpdaterTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { $viewModel = $this->controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } @@ -152,7 +156,12 @@ class StartUpdaterTest extends \PHPUnit_Framework_TestCase $content = '{"packages":[{"name":"vendor\/package","version":"1.0"}],"type":"update",' . '"headerTitle": "Update package 1" }'; $this->request->expects($this->any())->method('getContent')->willReturn($content); - $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false); + $write = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class, + [], + '', + false + ); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write); $write->expects($this->once()) ->method('writeFile') @@ -167,7 +176,12 @@ class StartUpdaterTest extends \PHPUnit_Framework_TestCase $content = '{"packages":[{"name":"vendor\/package","version":"1.0"}],"type":"upgrade",' . '"headerTitle": "System Upgrade" }'; $this->request->expects($this->any())->method('getContent')->willReturn($content); - $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false); + $write = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class, + [], + '', + false + ); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write); $write->expects($this->once()) ->method('writeFile') @@ -183,7 +197,12 @@ class StartUpdaterTest extends \PHPUnit_Framework_TestCase . '"headerTitle": "Enable Package 1" }'; $this->request->expects($this->any())->method('getContent')->willReturn($content); $this->fullModuleList->expects($this->once())->method('has')->willReturn(true); - $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false); + $write = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class, + [], + '', + false + ); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write); $write->expects($this->once()) ->method('writeFile') @@ -199,7 +218,12 @@ class StartUpdaterTest extends \PHPUnit_Framework_TestCase . '"headerTitle": "Disable Package 1" }'; $this->request->expects($this->any())->method('getContent')->willReturn($content); $this->fullModuleList->expects($this->once())->method('has')->willReturn(true); - $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false); + $write = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class, + [], + '', + false + ); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write); $write->expects($this->once()) ->method('writeFile') diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/SuccessTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/SuccessTest.php index 3375e88245c442b69e71bf6b342febdf843c8118..205931cbd129de980cd6eff40def5f80a3ef637e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/SuccessTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/SuccessTest.php @@ -12,18 +12,19 @@ class SuccessTest extends \PHPUnit_Framework_TestCase { public function testIndexAction() { - $moduleList = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false); + $moduleList = $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false); $moduleList->expects($this->once())->method('has')->willReturn(true); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = $this->getMock(\Magento\Framework\App\ObjectManager::class, [], [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); - $sampleDataState = $this->getMock('Magento\Framework\Setup\SampleData\State', ['hasError'], [], '', false); + $sampleDataState = + $this->getMock(\Magento\Framework\Setup\SampleData\State::class, ['hasError'], [], '', false); $objectManager->expects($this->once())->method('get')->willReturn($sampleDataState); /** @var $controller Success */ $controller = new Success($moduleList, $objectManagerProvider); $sampleDataState->expects($this->once())->method('hasError'); $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/SystemConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/SystemConfigTest.php index 94404e2e70fedf794db50b5460f3ce25a542d805..6ac823aad68ad3feb9a082572b61d42e82ddc099 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/SystemConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/SystemConfigTest.php @@ -18,7 +18,7 @@ class SystemConfigTest extends \PHPUnit_Framework_TestCase /** @var $controller SystemConfig */ $controller = new SystemConfig(); $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/UpdaterSuccessTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/UpdaterSuccessTest.php index 3c7edf00e79f066ea46fe8de60330eb8257d1472..9b4db8c5c81e0eaf917a464036d7cc4012af7663 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/UpdaterSuccessTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/UpdaterSuccessTest.php @@ -13,12 +13,12 @@ class UpdaterSuccessTest extends \PHPUnit_Framework_TestCase public function testIndexAction() { /** @var $maintenanceMode \Magento\Framework\App\MaintenanceMode */ - $maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); + $maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); $maintenanceMode->expects($this->once())->method('set')->with(false); /** @var $controller UpdaterSuccess */ $controller = new UpdaterSuccess($maintenanceMode); $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/WebConfigurationTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/WebConfigurationTest.php index 8aaca73901575c85f0cfdf40f85ffc96ea7c6498..829c64651e346427b6a66694562b9ad0c6418030 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/WebConfigurationTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/WebConfigurationTest.php @@ -16,7 +16,7 @@ class WebConfigurationTest extends \PHPUnit_Framework_TestCase $controller = new WebConfiguration(); $_SERVER['DOCUMENT_ROOT'] = 'some/doc/root/value'; $viewModel = $controller->indexAction(); - $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); + $this->assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel); $this->assertTrue($viewModel->terminate()); $this->assertArrayHasKey('autoBaseUrl', $viewModel->getVariables()); } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index 51e78d0560c7cc9380d4b097cf7d51eba196044e..9a871cbd196d2a40017b1864bcc00037fd27b31f 100755 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -8,6 +8,9 @@ namespace Magento\Setup\Test\Unit\Fixtures; use \Magento\Setup\Fixtures\CartPriceRulesFixture; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase { /** @@ -22,19 +25,19 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new CartPriceRulesFixture($this->fixtureModelMock); } public function testExecute() { - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->will($this->returnValue(2)); - $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); + $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); $websiteMock->expects($this->once()) ->method('getGroups') ->will($this->returnValue([$storeMock])); @@ -42,9 +45,9 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase ->method('getId') ->will($this->returnValue('website_id')); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [$contextMock], '', true, @@ -56,12 +59,12 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase ->method('getAllChildren') ->will($this->returnValue([1])); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') ->will($this->returnValue($abstractDbMock)); @@ -72,18 +75,18 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase ->method('getId') ->will($this->returnValue('category_id')); - $modelMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); - $modelFactoryMock = $this->getMock('\Magento\SalesRule\Model\RuleFactory', ['create'], [], '', false); + $modelMock = $this->getMock(\Magento\SalesRule\Model\Rule::class, [], [], '', false); + $modelFactoryMock = $this->getMock(\Magento\SalesRule\Model\RuleFactory::class, ['create'], [], '', false); $modelFactoryMock->expects($this->once()) ->method('create') ->willReturn($modelMock); $objectValueMap = [ - ['Magento\SalesRule\Model\RuleFactory', $modelFactoryMock], - ['Magento\Catalog\Model\Category', $categoryMock] + [\Magento\SalesRule\Model\RuleFactory::class, $modelFactoryMock], + [\Magento\Catalog\Model\Category::class, $categoryMock] ]; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->once()) ->method('create') ->will($this->returnValue($storeManagerMock)); @@ -111,13 +114,13 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $ruleMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); + $ruleMock = $this->getMock(\Magento\SalesRule\Model\Rule::class, [], [], '', false); $ruleMock->expects($this->never())->method('save'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('get') - ->with($this->equalTo('Magento\SalesRule\Model\Rule')) + ->with($this->equalTo(\Magento\SalesRule\Model\Rule::class)) ->willReturn($ruleMock); $this->fixtureModelMock @@ -148,14 +151,14 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase $result = $this->model->generateAdvancedCondition($ruleId, $categoriesArray); if ($ruleId < ($ruleCount - 200)) { $firstCondition = [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'attribute' => 'category_ids', 'operator' => '==', 'value' => null, ]; $secondCondition = [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'base_subtotal', 'operator' => '>=', 'value' => 5, @@ -163,13 +166,13 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase $expected = [ 'conditions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', ], '1--1'=> [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Found', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Found::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', @@ -179,7 +182,7 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase ], 'actions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', @@ -197,14 +200,14 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming']; $firstCondition = [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'region', 'operator' => '==', 'value' => $regions[($ruleId / 4) % 50], ]; $secondCondition = [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Address', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'base_subtotal', 'operator' => '>=', 'value' => 5, @@ -212,7 +215,7 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase $expected = [ 'conditions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', @@ -222,7 +225,7 @@ class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase ], 'actions' => [ 1 => [ - 'type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Combine', + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Combine::class, 'aggregator' => 'all', 'value' => '1', 'new_child' => '', diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php index 2d0aa2297b99a1a1cc546a002f8383896521a6b1..a3ed44dcf3d7a02bcc517a8d125f8f24de101c89 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CatalogPriceRulesFixtureTest.php @@ -8,6 +8,9 @@ namespace Magento\Setup\Test\Unit\Fixtures; use \Magento\Setup\Fixtures\CatalogPriceRulesFixture; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase { /** @@ -22,19 +25,19 @@ class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new CatalogPriceRulesFixture($this->fixtureModelMock); } public function testExecute() { - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->will($this->returnValue(2)); - $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); + $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); $websiteMock->expects($this->once()) ->method('getGroups') ->will($this->returnValue([$storeMock])); @@ -42,14 +45,14 @@ class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase ->method('getId') ->will($this->returnValue('website_id')); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [$contextMock], '', true, @@ -61,7 +64,7 @@ class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') ->will($this->returnValue($abstractDbMock)); @@ -72,24 +75,24 @@ class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase ->method('getId') ->will($this->returnValue('category_id')); - $modelMock = $this->getMock('Magento\CatalogRule\Model\Rule', [], [], '', false); - $metadataMock = $this->getMock('\Magento\Framework\EntityManager\EntityMetadata', [], [], '', false); - $metadataPoolMock = $this->getMock('Magento\Framework\EntityManager\MetadataPool', [], [], '', false); + $modelMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $metadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false); + $metadataPoolMock = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false); $metadataMock->expects($this->once()) ->method('getLinkField') ->will($this->returnValue('Field Id Name')); $valueMap = [ - ['Magento\CatalogRule\Model\Rule', $modelMock], - ['Magento\Catalog\Model\Category', $categoryMock], - ['Magento\Framework\EntityManager\MetadataPool', $metadataPoolMock] + [\Magento\CatalogRule\Model\Rule::class, $modelMock], + [\Magento\Catalog\Model\Category::class, $categoryMock], + [\Magento\Framework\EntityManager\MetadataPool::class, $metadataPoolMock] ]; $metadataPoolMock ->expects($this->once()) ->method('getMetadata') - ->with('Magento\CatalogRule\Api\Data\RuleInterface') + ->with(\Magento\CatalogRule\Api\Data\RuleInterface::class) ->willReturn($metadataMock); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->once()) ->method('create') ->will($this->returnValue($storeManagerMock)); @@ -111,13 +114,13 @@ class CatalogPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $ruleMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false); + $ruleMock = $this->getMock(\Magento\SalesRule\Model\Rule::class, [], [], '', false); $ruleMock->expects($this->never())->method('save'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('get') - ->with($this->equalTo('Magento\SalesRule\Model\Rule')) + ->with($this->equalTo(\Magento\SalesRule\Model\Rule::class)) ->willReturn($ruleMock); $this->fixtureModelMock diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php index a0b617954bf47c0b51be005fe6d31445e3b7fd18..4c44fb1cb059ff1ef4d4e19c5d9fbd2aea0c46c7 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CategoriesFixtureTest.php @@ -22,14 +22,14 @@ class CategoriesFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new CategoriesFixture($this->fixtureModelMock); } public function testExecute() { $categoryMock = $this->getMock( - '\Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [ 'getName', 'setId', @@ -82,22 +82,22 @@ class CategoriesFixtureTest extends \PHPUnit_Framework_TestCase ->method('setIsActive') ->willReturnSelf(); - $groupMock = $this->getMock('\Magento\Store\Model\Group', [], [], '', false); + $groupMock = $this->getMock(\Magento\Store\Model\Group::class, [], [], '', false); $groupMock->expects($this->once()) ->method('getRootCategoryId') ->will($this->returnValue('root_category_id')); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getGroups') ->will($this->returnValue([$groupMock])); $objectValueMock = [ - ['Magento\Store\Model\StoreManager', [], $storeManagerMock], - ['Magento\Catalog\Model\Category', [], $categoryMock] + [\Magento\Store\Model\StoreManager::class, [], $storeManagerMock], + [\Magento\Catalog\Model\Category::class, [], $categoryMock] ]; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->returnValueMap($objectValueMock)); @@ -121,13 +121,13 @@ class CategoriesFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $categoryMock = $this->getMock('\Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->never())->method('save'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('create') - ->with($this->equalTo('Magento\Catalog\Model\Category')) + ->with($this->equalTo(\Magento\Catalog\Model\Category::class)) ->willReturn($categoryMock); $this->fixtureModelMock diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php index 5daffed15806b45b58ba58b72cc6722e44f24495..aed093dad90c559c2918f04350de1c5dae5f434f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigsApplyFixtureTest.php @@ -23,17 +23,17 @@ class ConfigsApplyFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new ConfigsApplyFixture($this->fixtureModelMock); } public function testExecute() { - $cacheMock = $this->getMock('\Magento\Framework\App\Cache', [], [], '', false); + $cacheMock = $this->getMock(\Magento\Framework\App\Cache::class, [], [], '', false); - $valueMock = $this->getMock('\Magento\Framework\App\Config', [], [], '', false); + $valueMock = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->once()) ->method('get') ->will($this->returnValue($cacheMock)); @@ -52,10 +52,10 @@ class ConfigsApplyFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $configMock = $this->getMock('\Magento\Framework\App\Config\ValueInterface', [], [], '', false); + $configMock = $this->getMock(\Magento\Framework\App\Config\ValueInterface::class, [], [], '', false); $configMock->expects($this->never())->method('save'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('create') ->willReturn($configMock); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php index f84a59359f1b9126bcfcfed36db833a4f91e2992..9d72aaee102eddb2fb2acda24fb8644915ab7c2e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/ConfigurableProductsFixtureTest.php @@ -22,18 +22,18 @@ class ConfigurableProductsFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new ConfigurableProductsFixture($this->fixtureModelMock); } public function testExecute() { - $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [$contextMock], '', true, @@ -45,7 +45,7 @@ class ConfigurableProductsFixtureTest extends \PHPUnit_Framework_TestCase ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') ->will($this->returnValue($abstractDbMock)); @@ -59,12 +59,12 @@ class ConfigurableProductsFixtureTest extends \PHPUnit_Framework_TestCase ->method('load') ->willReturnSelf(); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->will($this->returnValue([2])); - $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); + $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); $websiteMock->expects($this->once()) ->method('getCode') ->will($this->returnValue('website_code')); @@ -72,14 +72,13 @@ class ConfigurableProductsFixtureTest extends \PHPUnit_Framework_TestCase ->method('getGroups') ->will($this->returnValue([$storeMock])); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->will($this->returnValue([$websiteMock])); $valueMap = [ - [ - 'Magento\ImportExport\Model\Import', + [\Magento\ImportExport\Model\Import::class, [ 'data' => [ 'entity' => 'catalog_product', @@ -89,10 +88,10 @@ class ConfigurableProductsFixtureTest extends \PHPUnit_Framework_TestCase ], $importMock ], - ['Magento\Store\Model\StoreManager', [], $storeManagerMock] + [\Magento\Store\Model\StoreManager::class, [], $storeManagerMock] ]; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->returnValueMap($valueMap)); @@ -114,14 +113,14 @@ class ConfigurableProductsFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); $importMock->expects($this->never())->method('validateSource'); $importMock->expects($this->never())->method('importSource'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('create') - ->with($this->equalTo('Magento\ImportExport\Model\Import')) + ->with($this->equalTo(\Magento\ImportExport\Model\Import::class)) ->willReturn($importMock); $this->fixtureModelMock diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php index 26eccf735e72b6bea751d3dc37da8ffc72ea3106..2ec140b4412ed177306aa3d019803b0c72faac3f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CustomersFixtureTest.php @@ -22,26 +22,26 @@ class CustomersFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new CustomersFixture($this->fixtureModelMock); } public function testExecute() { - $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->once()) ->method('getCode') ->will($this->returnValue('store_code')); - $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); + $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); $websiteMock->expects($this->once()) ->method('getCode') ->will($this->returnValue('website_code')); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getDefaultStoreView') ->will($this->returnValue($storeMock)); @@ -51,7 +51,7 @@ class CustomersFixtureTest extends \PHPUnit_Framework_TestCase $valueMap = [ [ - 'Magento\ImportExport\Model\Import', + \Magento\ImportExport\Model\Import::class, [ 'data' => [ 'entity' => 'customer_composite', @@ -61,10 +61,10 @@ class CustomersFixtureTest extends \PHPUnit_Framework_TestCase ], $importMock ], - ['Magento\Store\Model\StoreManager', [], $storeManagerMock] + [\Magento\Store\Model\StoreManager::class, [], $storeManagerMock] ]; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->returnValueMap($valueMap)); @@ -83,14 +83,14 @@ class CustomersFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); $importMock->expects($this->never())->method('validateSource'); $importMock->expects($this->never())->method('importSource'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('create') - ->with($this->equalTo('Magento\ImportExport\Model\Import')) + ->with($this->equalTo(\Magento\ImportExport\Model\Import::class)) ->willReturn($importMock); $this->fixtureModelMock diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php index ed41b7d7863bc6bef65984c6cb1e825cc2709eed..9ed90b34dd6a4a2d233647566d0c9d8e11758b0b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/EavVariationsFixtureTest.php @@ -23,7 +23,7 @@ class EavVariationsFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new EavVariationsFixture($this->fixtureModelMock); } @@ -31,7 +31,7 @@ class EavVariationsFixtureTest extends \PHPUnit_Framework_TestCase public function testExecute() { $attributeMock = $this->getMock( - 'Magento\Catalog\Model\ResourceModel\Eav\Attribute', + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [ 'setAttributeSetId', 'setAttributeGroupId', @@ -48,28 +48,28 @@ class EavVariationsFixtureTest extends \PHPUnit_Framework_TestCase ->method('setAttributeGroupId') ->willReturnSelf(); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getStores') ->will($this->returnValue([$storeMock])); - $setMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false); + $setMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); $setMock->expects($this->once()) ->method('getDefaultGroupId') ->will($this->returnValue(2)); - $cacheMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false); + $cacheMock = $this->getMock(\Magento\Framework\App\CacheInterface::class, [], [], '', false); $valueMap = [ - ['Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], $attributeMock], - ['Magento\Store\Model\StoreManager', [], $storeManagerMock], - ['Magento\Eav\Model\Entity\Attribute\Set', $setMock], - ['Magento\Framework\App\CacheInterface', $cacheMock] + [\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], $attributeMock], + [\Magento\Store\Model\StoreManager::class, [], $storeManagerMock], + [\Magento\Eav\Model\Entity\Attribute\Set::class, $setMock], + [\Magento\Framework\App\CacheInterface::class, $cacheMock] ]; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->returnValueMap($valueMap)); @@ -91,13 +91,13 @@ class EavVariationsFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $attributeMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false); + $attributeMock = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false); $attributeMock->expects($this->never())->method('save'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('create') - ->with($this->equalTo('Magento\Catalog\Model\ResourceModel\Eav\Attribute')) + ->with($this->equalTo(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)) ->willReturn($attributeMock); $this->fixtureModelMock diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php index 1db8a46a1eeeb5b38b8dcce8f6cd4660e2d5df17..ee1369bd15d5a46f084a504fdfedbf61eb53f8bc 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/FixtureModelTest.php @@ -19,20 +19,20 @@ class FixtureModelTest extends \PHPUnit_Framework_TestCase public function setUp() { $reindexCommandMock = $this->getMock( - '\Magento\Indexer\Console\Command\IndexerReindexCommand', + \Magento\Indexer\Console\Command\IndexerReindexCommand::class, [], [], '', false ); - $fileParserMock = $this->getMock('\Magento\Framework\Xml\Parser', [], [], '', false); + $fileParserMock = $this->getMock(\Magento\Framework\Xml\Parser::class, [], [], '', false); $this->model = new FixtureModel($reindexCommandMock, $fileParserMock); } public function testReindex() { - $outputMock = $this->getMock('\Symfony\Component\Console\Output\OutputInterface', [], [], '', false); + $outputMock = $this->getMock(\Symfony\Component\Console\Output\OutputInterface::class, [], [], '', false); $this->model->reindex($outputMock); } @@ -48,14 +48,14 @@ class FixtureModelTest extends \PHPUnit_Framework_TestCase public function testLoadConfig() { $reindexCommandMock = $this->getMock( - '\Magento\Indexer\Console\Command\IndexerReindexCommand', + \Magento\Indexer\Console\Command\IndexerReindexCommand::class, [], [], '', false ); - $fileParserMock = $this->getMock('\Magento\Framework\Xml\Parser', ['load', 'xmlToArray'], [], '', false); + $fileParserMock = $this->getMock(\Magento\Framework\Xml\Parser::class, ['load', 'xmlToArray'], [], '', false); $fileParserMock->expects($this->once())->method('xmlToArray')->willReturn( ['config' => [ 'profile' => ['some_key' => 'some_value']]] ); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php index d2a9ffcb36f1f588bc1f2acda9e1e23baaea1d64..56fa29d6d4b8c4021458fc331853542b3c562129 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/IndexersStatesApplyFixtureTest.php @@ -22,16 +22,16 @@ class IndexersStatesApplyFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new IndexersStatesApplyFixture($this->fixtureModelMock); } public function testExecute() { - $cacheInterfaceMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false); + $cacheInterfaceMock = $this->getMock(\Magento\Framework\App\CacheInterface::class, [], [], '', false); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->once()) ->method('get') ->willReturn($cacheInterfaceMock); @@ -52,10 +52,10 @@ class IndexersStatesApplyFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $cacheInterfaceMock = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false); + $cacheInterfaceMock = $this->getMock(\Magento\Framework\App\CacheInterface::class, [], [], '', false); $cacheInterfaceMock->expects($this->never())->method('clean'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('get') ->willReturn($cacheInterfaceMock); diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index 40ea93805f2900bf96295f97f0e4b9276b94cf52..4b0e6d7a648acdd4cc1a2d9dc54c59ea96337165 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -8,6 +8,9 @@ namespace Magento\Setup\Test\Unit\Fixtures; use \Magento\Setup\Fixtures\OrdersFixture; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase { @@ -23,7 +26,7 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new OrdersFixture($this->fixtureModelMock); } @@ -35,19 +38,19 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase public function testExecute() { $mockObjectNames = [ - 'Magento\Quote\Model\ResourceModel\Quote', - 'Magento\Quote\Model\ResourceModel\Quote\Address', - 'Magento\Quote\Model\ResourceModel\Quote\Item', - 'Magento\Quote\Model\ResourceModel\Quote\Item\Option', - 'Magento\Quote\Model\ResourceModel\Quote\Payment', - 'Magento\Quote\Model\ResourceModel\Quote\Address\Rate', - 'Magento\Reports\Model\ResourceModel\Event', - 'Magento\Sales\Model\ResourceModel\Order', - 'Magento\Sales\Model\ResourceModel\Order\Grid', - 'Magento\Sales\Model\ResourceModel\Order\Item', - 'Magento\Sales\Model\ResourceModel\Order\Payment', - 'Magento\Sales\Model\ResourceModel\Order\Status\History', - '\Magento\Eav\Model\ResourceModel\Entity\Store' + \Magento\Quote\Model\ResourceModel\Quote::class, + \Magento\Quote\Model\ResourceModel\Quote\Address::class, + \Magento\Quote\Model\ResourceModel\Quote\Item::class, + \Magento\Quote\Model\ResourceModel\Quote\Item\Option::class, + \Magento\Quote\Model\ResourceModel\Quote\Payment::class, + \Magento\Quote\Model\ResourceModel\Quote\Address\Rate::class, + \Magento\Reports\Model\ResourceModel\Event::class, + \Magento\Sales\Model\ResourceModel\Order::class, + \Magento\Sales\Model\ResourceModel\Order\Grid::class, + \Magento\Sales\Model\ResourceModel\Order\Item::class, + \Magento\Sales\Model\ResourceModel\Order\Payment::class, + \Magento\Sales\Model\ResourceModel\Order\Status\History::class, + \Magento\Eav\Model\ResourceModel\Entity\Store::class ]; $mockObjects = []; @@ -55,7 +58,7 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase $mockObject = $this->getMock($mockObjectName, ['getTable'], [], '', false); $path = explode('\\', $mockObjectName); $name = array_pop($path); - if (strcasecmp($mockObjectName, 'Magento\Sales\Model\ResourceModel\Order') == 0) { + if (strcasecmp($mockObjectName, \Magento\Sales\Model\ResourceModel\Order::class) == 0) { $mockObject->expects($this->exactly(2)) ->method('getTable') ->willReturn(strtolower($name) . '_table_name'); @@ -68,7 +71,7 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase } $connectionInterfaceMock = $this->getMockForAbstractClass( - '\Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', true, @@ -80,12 +83,12 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase ->method('getTableName') ->willReturn('table_name'); - $resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $resourceMock->expects($this->exactly(15)) ->method('getConnection') ->willReturn($connectionInterfaceMock); - $websiteMock = $this->getMock('\Magento\Store\Model\Website', ['getId', 'getName'], [], '', false); + $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, ['getId', 'getName'], [], '', false); $websiteMock->expects($this->once()) ->method('getId') ->willReturn('website_id'); @@ -93,13 +96,13 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase ->method('getName') ->willReturn('website_name'); - $groupMock = $this->getMock('\Magento\Store\Model\Group', ['getName'], [], '', false); + $groupMock = $this->getMock(\Magento\Store\Model\Group::class, ['getName'], [], '', false); $groupMock->expects($this->once()) ->method('getName') ->willReturn('group_name'); $storeMock = $this->getMock( - '\Magento\Store\Model\Store', + \Magento\Store\Model\Store::class, [ 'getStoreId', 'getWebsite', @@ -127,14 +130,14 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase ->method('getRootCategoryId') ->willReturn(1); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getStores') ->willReturn([$storeMock]); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [$contextMock], '', true, @@ -146,7 +149,7 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') ->willReturn($abstractDbMock); @@ -160,7 +163,8 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase ->method('load') ->willReturnSelf(); - $productMock = $this->getMock('\Magento\Catalog\Model\Product', ['load', 'getSku', 'getName'], [], '', false); + $productMock = + $this->getMock(\Magento\Catalog\Model\Product::class, ['load', 'getSku', 'getName'], [], '', false); $productMock->expects($this->exactly(2)) ->method('load') ->willReturnSelf(); @@ -171,9 +175,10 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase ->method('getName') ->willReturn('product_name'); - $selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); - $collectionMock = $this->getMock('\Magento\Catalog\Model\ResourceModel\Product\Collection', [], [], '', false); + $collectionMock = + $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, [], [], '', false); $collectionMock->expects($this->once()) ->method('getSelect') ->willReturn($selectMock); @@ -183,14 +188,14 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase array_push( $mockObjects, - ['Magento\Store\Model\StoreManager', [], $storeManagerMock], - ['Magento\Catalog\Model\Category', $categoryMock], - ['Magento\Catalog\Model\Product', $productMock], - ['Magento\Framework\App\ResourceConnection', $resourceMock], - ['Magento\Catalog\Model\ResourceModel\Product\Collection', [], $collectionMock] + [\Magento\Store\Model\StoreManager::class, [], $storeManagerMock], + [\Magento\Catalog\Model\Category::class, $categoryMock], + [\Magento\Catalog\Model\Product::class, $productMock], + [\Magento\Framework\App\ResourceConnection::class, $resourceMock], + [\Magento\Catalog\Model\ResourceModel\Product\Collection::class, [], $collectionMock] ); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->exactly(32)) ->method('get') ->will($this->returnValueMap($mockObjects)); @@ -213,7 +218,7 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { $connectionMock = $this->getMockForAbstractClass( - '\Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', true, @@ -224,16 +229,16 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase $connectionMock->expects($this->never()) ->method('query'); - $resourceMock = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $resourceMock->expects($this->never()) ->method('getConnection') ->with($this->equalTo('write')) ->willReturn($connectionMock); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('get') - ->with($this->equalTo('Magento\Framework\App\ResourceConnection')) + ->with($this->equalTo(\Magento\Framework\App\ResourceConnection::class)) ->willReturn($resourceMock); $this->fixtureModelMock diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php index 2a4edd81bf5c4f61358dd6bfdfcd42065424e0ff..913b2a1e3f02048ac4c61b894e287791ce421207 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/SimpleProductsFixtureTest.php @@ -22,19 +22,19 @@ class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new SimpleProductsFixture($this->fixtureModelMock); } public function testExecute() { - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->willReturn(1); - $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); + $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); $websiteMock->expects($this->once()) ->method('getCode') ->willReturn('website_code'); @@ -42,16 +42,16 @@ class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase ->method('getGroups') ->willReturn([$storeMock]); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsites') ->willReturn([$websiteMock]); - $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); - $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); + $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); $abstractDbMock = $this->getMockForAbstractClass( - '\Magento\Framework\Model\ResourceModel\Db\AbstractDb', + \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [$contextMock], '', true, @@ -63,7 +63,7 @@ class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase ->method('getAllChildren') ->will($this->returnValue([1])); - $categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false); + $categoryMock = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); $categoryMock->expects($this->once()) ->method('getResource') ->willReturn($abstractDbMock); @@ -79,7 +79,7 @@ class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase $valueMap = [ [ - 'Magento\ImportExport\Model\Import', + \Magento\ImportExport\Model\Import::class, [ 'data' => [ 'entity' => 'catalog_product', @@ -89,10 +89,10 @@ class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase ], $importMock ], - ['Magento\Store\Model\StoreManager', [], $storeManagerMock] + [\Magento\Store\Model\StoreManager::class, [], $storeManagerMock] ]; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->returnValueMap($valueMap)); @@ -114,14 +114,14 @@ class SimpleProductsFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $importMock = $this->getMock('\Magento\ImportExport\Model\Import', [], [], '', false); + $importMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); $importMock->expects($this->never())->method('validateSource'); $importMock->expects($this->never())->method('importSource'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('create') - ->with($this->equalTo('Magento\ImportExport\Model\Import')) + ->with($this->equalTo(\Magento\ImportExport\Model\Import::class)) ->willReturn($importMock); $this->fixtureModelMock diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php index 474f9b6840620e8f349428fbd852ce9c2d136291..7c1c37cc81a5e53203a13bb1f70f99253cccd737 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/StoresFixtureTest.php @@ -23,7 +23,7 @@ class StoresFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new StoresFixture($this->fixtureModelMock); } @@ -34,21 +34,21 @@ class StoresFixtureTest extends \PHPUnit_Framework_TestCase */ public function testExecute() { - $websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false); + $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); $websiteMock->expects($this->exactly(2)) ->method('getId') ->willReturn('website_id'); $websiteMock->expects($this->once()) ->method('save'); - $groupMock = $this->getMock('\Magento\Store\Model\Group', [], [], '', false); + $groupMock = $this->getMock(\Magento\Store\Model\Group::class, [], [], '', false); $groupMock->expects($this->exactly(2)) ->method('getId') ->willReturn('group_id'); $groupMock->expects($this->once()) ->method('save'); - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->once()) ->method('getRootCategoryId') ->willReturn(1); @@ -58,7 +58,7 @@ class StoresFixtureTest extends \PHPUnit_Framework_TestCase $storeMock->expects($this->once()) ->method('save'); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->once()) ->method('getWebsite') ->willReturn($websiteMock); @@ -73,7 +73,7 @@ class StoresFixtureTest extends \PHPUnit_Framework_TestCase ->willReturn($storeMock); $categoryMock = $this->getMock( - 'Magento\Catalog\Model\Category', + \Magento\Catalog\Model\Category::class, [ 'setName', 'setPath', @@ -112,11 +112,11 @@ class StoresFixtureTest extends \PHPUnit_Framework_TestCase ->willReturn('category_id'); $valueMap = [ - ['Magento\Store\Model\StoreManager', [], $storeManagerMock], - ['Magento\Catalog\Model\Category', [], $categoryMock] + [\Magento\Store\Model\StoreManager::class, [], $storeManagerMock], + [\Magento\Catalog\Model\Category::class, [], $categoryMock] ]; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('create') ->will($this->returnValueMap($valueMap)); @@ -135,18 +135,18 @@ class StoresFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { - $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); $storeMock->expects($this->never())->method('save'); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); $storeManagerMock->expects($this->never()) ->method('getDefaultStoreView') ->willReturn($storeMock); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('create') - ->with($this->equalTo('Magento\Store\Model\StoreManager')) + ->with($this->equalTo(\Magento\Store\Model\StoreManager::class)) ->willReturn($storeManagerMock); $this->fixtureModelMock diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php index e8bd29cb9bb50cb86f1f384b9f308281577a2071..f7a4cc777b3347d1b8f04e77b75fd6ce0e021743 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/TaxRatesFixtureTest.php @@ -23,23 +23,23 @@ class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->fixtureModelMock = $this->getMock(\Magento\Setup\Fixtures\FixtureModel::class, [], [], '', false); $this->model = new TaxRatesFixture($this->fixtureModelMock); } public function testExecute() { - $rateMock = $this->getMock('Magento\Tax\Model\Calculation\Rate', ['setId', 'delete'], [], '', false); + $rateMock = $this->getMock(\Magento\Tax\Model\Calculation\Rate::class, ['setId', 'delete'], [], '', false); $collectionMock = - $this->getMock('Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection', [], [], '', false); + $this->getMock(\Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection::class, [], [], '', false); $collectionMock->expects($this->once()) ->method('getAllIds') ->willReturn([1]); $csvImportHandlerMock = $this->getMock( - 'Magento\TaxImportExport\Model\Rate\CsvImportHandler', + \Magento\TaxImportExport\Model\Rate\CsvImportHandler::class, [], [], '', @@ -47,11 +47,11 @@ class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase ); $valueMap = [ - ['Magento\Tax\Model\Calculation\Rate', $rateMock], - ['Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection', $collectionMock] + [\Magento\Tax\Model\Calculation\Rate::class, $rateMock], + [\Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection::class, $collectionMock] ]; - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->exactly(2)) ->method('get') ->will($this->returnValueMap($valueMap)); @@ -74,7 +74,7 @@ class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase public function testNoFixtureConfigValue() { $csvImportHandlerMock = $this->getMock( - 'Magento\TaxImportExport\Model\Rate\CsvImportHandler', + \Magento\TaxImportExport\Model\Rate\CsvImportHandler::class, [], [], '', @@ -82,7 +82,7 @@ class TaxRatesFixtureTest extends \PHPUnit_Framework_TestCase ); $csvImportHandlerMock->expects($this->never())->method('importFromCsvFile'); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); $objectManagerMock->expects($this->never()) ->method('create') ->willReturn($csvImportHandlerMock); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/AdminAccountFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/AdminAccountFactoryTest.php index cc234ddae9872e202f2a72d99a96a7dc97b706f8..79f393ff6cc1af43cc77d26ad47e91a99207f54e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/AdminAccountFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/AdminAccountFactoryTest.php @@ -12,17 +12,18 @@ class AdminAccountFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $serviceLocatorMock = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface', ['get']); + $serviceLocatorMock = + $this->getMockForAbstractClass(\Zend\ServiceManager\ServiceLocatorInterface::class, ['get']); $serviceLocatorMock ->expects($this->once()) ->method('get') - ->with('Magento\Framework\Encryption\Encryptor') - ->willReturn($this->getMockForAbstractClass('Magento\Framework\Encryption\EncryptorInterface')); + ->with(\Magento\Framework\Encryption\Encryptor::class) + ->willReturn($this->getMockForAbstractClass(\Magento\Framework\Encryption\EncryptorInterface::class)); $adminAccountFactory = new AdminAccountFactory($serviceLocatorMock); $adminAccount = $adminAccountFactory->create( - $this->getMock('Magento\Setup\Module\Setup', [], [], '', false), + $this->getMock(\Magento\Setup\Module\Setup::class, [], [], '', false), [] ); - $this->assertInstanceOf('Magento\Setup\Model\AdminAccount', $adminAccount); + $this->assertInstanceOf(\Magento\Setup\Model\AdminAccount::class, $adminAccount); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/AdminAccountTest.php b/setup/src/Magento/Setup/Test/Unit/Model/AdminAccountTest.php index ee44afcfcf534499349fffdb352fefe0b8e89b74..fc7a79260d1f8a42d1d5f2ac5a27eba1810bd06d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/AdminAccountTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/AdminAccountTest.php @@ -32,9 +32,9 @@ class AdminAccountTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->setUpMock = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false); + $this->setUpMock = $this->getMock(\Magento\Setup\Module\Setup::class, [], [], '', false); - $this->dbAdapterMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $this->dbAdapterMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); $this->setUpMock ->expects($this->any()) @@ -50,7 +50,7 @@ class AdminAccountTest extends \PHPUnit_Framework_TestCase } )); - $this->encryptor = $this->getMockBuilder('Magento\Framework\Encryption\EncryptorInterface') + $this->encryptor = $this->getMockBuilder(\Magento\Framework\Encryption\EncryptorInterface::class) ->getMockForAbstractClass(); $data = [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigGeneratorTest.php index 21f0bbb6516766bb1f9599f2dfa06bb97fbde05b..033ab78c69cd01220f9bb04fc2946db16d0afb59 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigGeneratorTest.php @@ -20,11 +20,11 @@ class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->deploymentConfigMock = $this->getMockBuilder('Magento\Framework\App\DeploymentConfig') + $this->deploymentConfigMock = $this->getMockBuilder(\Magento\Framework\App\DeploymentConfig::class) ->disableOriginalConstructor() ->getMock(); $this->model = $objectManager->getObject( - 'Magento\Setup\Model\ConfigGenerator', + \Magento\Setup\Model\ConfigGenerator::class, ['deploymentConfig' => $this->deploymentConfigMock] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigModelTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigModelTest.php index 53ce6bfd204f5556b6134971efcf0184e65d810f..22dd0581864aee513c97cf2706d5d1879bed6a85 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigModelTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigModelTest.php @@ -48,12 +48,12 @@ class ConfigModelTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->collector = $this->getMock('Magento\Setup\Model\ConfigOptionsListCollector', [], [], '', false); - $this->writer = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->configOptionsList = $this->getMock('Magento\Backend\Setup\ConfigOptionsList', [], [], '', false); - $this->configData = $this->getMock('Magento\Framework\Config\Data\ConfigData', [], [], '', false); - $this->filePermissions = $this->getMock('\Magento\Framework\Setup\FilePermissions', [], [], '', false); + $this->collector = $this->getMock(\Magento\Setup\Model\ConfigOptionsListCollector::class, [], [], '', false); + $this->writer = $this->getMock(\Magento\Framework\App\DeploymentConfig\Writer::class, [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->configOptionsList = $this->getMock(\Magento\Backend\Setup\ConfigOptionsList::class, [], [], '', false); + $this->configData = $this->getMock(\Magento\Framework\Config\Data\ConfigData::class, [], [], '', false); + $this->filePermissions = $this->getMock(\Magento\Framework\Setup\FilePermissions::class, [], [], '', false); $this->deploymentConfig->expects($this->any())->method('get'); @@ -67,7 +67,7 @@ class ConfigModelTest extends \PHPUnit_Framework_TestCase public function testValidate() { - $option = $this->getMock('Magento\Framework\Setup\Option\TextConfigOption', [], [], '', false); + $option = $this->getMock(\Magento\Framework\Setup\Option\TextConfigOption::class, [], [], '', false); $option->expects($this->exactly(3))->method('getName')->willReturn('Fake'); $optionsSet = [ $option, diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php index 4f09d2751f6b7d2a333550fa5673f670e97f861e..1e37d351d8f039014ae35a9fdfbe3aaa725375fe 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php @@ -35,50 +35,50 @@ class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->generator = $this->getMock('Magento\Setup\Model\ConfigGenerator', [], [], '', false); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false); + $this->generator = $this->getMock(\Magento\Setup\Model\ConfigGenerator::class, [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->dbValidator = $this->getMock(\Magento\Setup\Validator\DbValidator::class, [], [], '', false); $this->object = new ConfigOptionsList($this->generator, $this->dbValidator); } public function testGetOptions() { $options = $this->object->getOptions(); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[0]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[0]); $this->assertSame('Encryption key', $options[0]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\SelectConfigOption', $options[1]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\SelectConfigOption::class, $options[1]); $this->assertSame('Session save handler', $options[1]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\SelectConfigOption', $options[2]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\SelectConfigOption::class, $options[2]); $this->assertSame('Type of definitions used by Object Manager', $options[2]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[3]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[3]); $this->assertSame('Database server host', $options[3]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[4]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[4]); $this->assertSame('Database name', $options[4]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[5]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[5]); $this->assertSame('Database server username', $options[5]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[6]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[6]); $this->assertSame('Database server engine', $options[6]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[7]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[7]); $this->assertSame('Database server password', $options[7]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[8]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[8]); $this->assertSame('Database table prefix', $options[8]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[9]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[9]); $this->assertSame('Database type', $options[9]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[10]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[10]); $this->assertSame('Database initial set of commands', $options[10]->getDescription()); - $this->assertInstanceOf('Magento\Framework\Setup\Option\FlagConfigOption', $options[11]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\FlagConfigOption::class, $options[11]); $this->assertSame( 'If specified, then db connection validation will be skipped', $options[11]->getDescription() ); - $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[12]); + $this->assertInstanceOf(\Magento\Framework\Setup\Option\TextConfigOption::class, $options[12]); $this->assertSame('http Cache hosts', $options[12]->getDescription()); $this->assertEquals(13, count($options)); } public function testCreateOptions() { - $configDataMock = $this->getMock('Magento\Framework\Config\Data\ConfigData', [], [], '', false); + $configDataMock = $this->getMock(\Magento\Framework\Config\Data\ConfigData::class, [], [], '', false); $this->generator->expects($this->once())->method('createCryptConfig')->willReturn($configDataMock); $this->generator->expects($this->once())->method('createSessionConfig')->willReturn($configDataMock); $this->generator->expects($this->once())->method('createDefinitionsConfig')->willReturn($configDataMock); @@ -92,7 +92,7 @@ class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase public function testCreateOptionsWithOptionalNull() { - $configDataMock = $this->getMock('Magento\Framework\Config\Data\ConfigData', [], [], '', false); + $configDataMock = $this->getMock(\Magento\Framework\Config\Data\ConfigData::class, [], [], '', false); $this->generator->expects($this->once())->method('createCryptConfig')->willReturn($configDataMock); $this->generator->expects($this->once())->method('createSessionConfig')->willReturn($configDataMock); $this->generator->expects($this->once())->method('createDefinitionsConfig')->willReturn(null); @@ -141,7 +141,7 @@ class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase private function prepareValidationMocks() { - $configDataMock = $this->getMockBuilder('Magento\Framework\Config\Data\ConfigData') + $configDataMock = $this->getMockBuilder(\Magento\Framework\Config\Data\ConfigData::class) ->disableOriginalConstructor() ->getMock(); $this->dbValidator->expects($this->once())->method('checkDatabaseTablePrefix')->willReturn($configDataMock); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/Helper/ModuleUninstallTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/Helper/ModuleUninstallTest.php index ef3f8653ab30f31100758f08dc7d6fd89e056727..4fe96a37c724a024c77ad6ddb6921fe49de30521 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/Helper/ModuleUninstallTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/Helper/ModuleUninstallTest.php @@ -11,14 +11,16 @@ class ModuleUninstallTest extends \PHPUnit_Framework_TestCase { public function testUninstallRemoveData() { - $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); - $packageInfoFactory = $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); - $packageInfo = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $output = + $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class, [], '', false); + $packageInfoFactory = $this->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false); + $packageInfo = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $packageInfo->expects($this->once())->method('getModuleName')->willReturn('Module_A'); $packageInfoFactory->expects($this->any())->method('create')->willReturn($packageInfo); - $moduleUninstaller = $this->getMock('Magento\Setup\Model\ModuleUninstaller', [], [], '', false); + $moduleUninstaller = $this->getMock(\Magento\Setup\Model\ModuleUninstaller::class, [], [], '', false); $moduleUninstaller->expects($this->once())->method('uninstallData')->with($output, ['Module_A']); - $moduleRegistryUninstaller = $this->getMock('Magento\Setup\Model\ModuleRegistryUninstaller', [], [], '', false); + $moduleRegistryUninstaller = + $this->getMock(\Magento\Setup\Model\ModuleRegistryUninstaller::class, [], [], '', false); $moduleRegistryUninstaller->expects($this->once())->method('removeModulesFromDb')->with($output, ['Module_A']); $moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') @@ -30,14 +32,16 @@ class ModuleUninstallTest extends \PHPUnit_Framework_TestCase public function testUninstallNotRemoveData() { - $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); - $packageInfoFactory = $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); - $packageInfo = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $output = + $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class, [], '', false); + $packageInfoFactory = $this->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false); + $packageInfo = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $packageInfo->expects($this->once())->method('getModuleName')->willReturn('Module_A'); $packageInfoFactory->expects($this->any())->method('create')->willReturn($packageInfo); - $moduleUninstaller = $this->getMock('Magento\Setup\Model\ModuleUninstaller', [], [], '', false); + $moduleUninstaller = $this->getMock(\Magento\Setup\Model\ModuleUninstaller::class, [], [], '', false); $moduleUninstaller->expects($this->never())->method('uninstallData'); - $moduleRegistryUninstaller = $this->getMock('Magento\Setup\Model\ModuleRegistryUninstaller', [], [], '', false); + $moduleRegistryUninstaller = + $this->getMock(\Magento\Setup\Model\ModuleRegistryUninstaller::class, [], [], '', false); $moduleRegistryUninstaller->expects($this->once())->method('removeModulesFromDb')->with($output, ['Module_A']); $moduleRegistryUninstaller->expects($this->once()) ->method('removeModulesFromDeploymentConfig') diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/Helper/ThemeUninstallTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/Helper/ThemeUninstallTest.php index acb098b14db6af439a7533c7b3bd7cf93433727b..923a4c16d2f131a55898737caeb301e95a04452e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/Helper/ThemeUninstallTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/Helper/ThemeUninstallTest.php @@ -11,9 +11,10 @@ class ThemeUninstallTest extends \PHPUnit_Framework_TestCase { public function testUninstall() { - $themeUninstaller = $this->getMock('Magento\Theme\Model\Theme\ThemeUninstaller', [], [], '', false); - $themePackageInfo = $this->getMock('Magento\Theme\Model\Theme\ThemePackageInfo', [], [], '', false); - $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); + $themeUninstaller = $this->getMock(\Magento\Theme\Model\Theme\ThemeUninstaller::class, [], [], '', false); + $themePackageInfo = $this->getMock(\Magento\Theme\Model\Theme\ThemePackageInfo::class, [], [], '', false); + $output = + $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class, [], '', false); $themePackageInfo->expects($this->once())->method('getFullThemePath')->willReturn('theme/path'); $themeUninstaller->expects($this->once())->method('uninstallRegistry')->with($output, ['theme/path']); $themeUninstall = new ThemeUninstall($themeUninstaller, $themePackageInfo); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobComponentUninstallTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobComponentUninstallTest.php index e08760a14041271620b5f75da780e7bfd7b55aa4..a3a1f6d9e9bc4b80c222661e740aec9bc2a93f17 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobComponentUninstallTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobComponentUninstallTest.php @@ -9,6 +9,9 @@ use Magento\Framework\ObjectManagerInterface; use Magento\Setup\Model\Cron\ComponentUninstallerFactory; use Magento\Setup\Model\Cron\JobComponentUninstall; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class JobComponentUninstallTest extends \PHPUnit_Framework_TestCase { /** @@ -64,47 +67,48 @@ class JobComponentUninstallTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->output = $this->getMockForAbstractClass( - 'Symfony\Component\Console\Output\OutputInterface', + \Symfony\Component\Console\Output\OutputInterface::class, [], '', false ); - $this->status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); + $this->status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); $this->moduleUninstallHelper = $this->getMock( - 'Magento\Setup\Model\Cron\Helper\ModuleUninstall', + \Magento\Setup\Model\Cron\Helper\ModuleUninstall::class, [], [], '', false ); $this->themeUninstallHelper = $this->getMock( - 'Magento\Setup\Model\Cron\Helper\ThemeUninstall', + \Magento\Setup\Model\Cron\Helper\ThemeUninstall::class, [], [], '', false ); $this->composerInformation = $this->getMock( - 'Magento\Framework\Composer\ComposerInformation', + \Magento\Framework\Composer\ComposerInformation::class, [], [], '', false ); - $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $this->objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false ); - $packageInfoFactory = $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); - $packageInfo = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $packageInfoFactory = $this->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false); + $packageInfo = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $packageInfoFactory->expects($this->any())->method('create')->willReturn($packageInfo); $this->objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); - $this->updater = $this->getMock('Magento\Setup\Model\Updater', [], [], '', false); - $this->quence = $this->getMock('Magento\Setup\Model\Cron\Queue', ['addJobs'], [], '', false); + $this->updater = $this->getMock(\Magento\Setup\Model\Updater::class, [], [], '', false); + $this->quence = $this->getMock(\Magento\Setup\Model\Cron\Queue::class, ['addJobs'], [], '', false); } private function setUpUpdater() diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobDbRollbackTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobDbRollbackTest.php index 13c01c0e7d5a12a246489ba10a0f56663cdb33ac..d1b084d3d853f0397e348cfd5802389703519f59 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobDbRollbackTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobDbRollbackTest.php @@ -37,37 +37,40 @@ class JobDbRollbackTest extends \PHPUnit_Framework_TestCase public function setup() { $this->backupRollbackFactory = $this->getMock( - 'Magento\Framework\Setup\BackupRollbackFactory', + \Magento\Framework\Setup\BackupRollbackFactory::class, [], [], '', false ); - $this->backupRollback = $this->getMock('\Magento\Framework\Setup\BackupRollback', [], [], '', false); - $this->status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); - $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); - $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $this->backupRollback = $this->getMock(\Magento\Framework\Setup\BackupRollback::class, [], [], '', false); + $this->status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); + $output = + $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class, [], '', false); + $this->objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $appState = $this->getMock( - 'Magento\Framework\App\State', + \Magento\Framework\App\State::class, [], [], '', false ); $configLoader = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManager\ConfigLoaderInterface', + \Magento\Framework\ObjectManager\ConfigLoaderInterface::class, [], '', false ); $configLoader->expects($this->any())->method('load')->willReturn([]); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); + $objectManager = + $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class, [], '', false); $objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ - ['Magento\Framework\App\State', $appState], - ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], + [\Magento\Framework\App\State::class, $appState], + [\Magento\Framework\ObjectManager\ConfigLoaderInterface::class, $configLoader], ])); $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php index 5048b8ad9091eaa7b6a6d842ad54dd03cfe905b6..31e241c408dbacc65dccc7821aea79bd4018c1bb 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php @@ -7,6 +7,9 @@ namespace Magento\Setup\Test\Unit\Model\Cron; use Magento\Setup\Model\Cron\JobFactory; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class JobFactoryTest extends \PHPUnit_Framework_TestCase { /** @@ -21,39 +24,40 @@ class JobFactoryTest extends \PHPUnit_Framework_TestCase public function setUp() { - $serviceManager = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface', [], '', false); - $status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); + $serviceManager = + $this->getMockForAbstractClass(\Zend\ServiceManager\ServiceLocatorInterface::class, [], '', false); + $status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); $status->expects($this->once())->method('getStatusFilePath')->willReturn('path_a'); $status->expects($this->once())->method('getLogFilePath')->willReturn('path_b'); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false ); $objectManagerProvider->expects($this->atLeastOnce())->method('get')->willReturn($this->objectManager); - $upgradeCommand = $this->getMock('Magento\Setup\Console\Command\UpgradeCommand', [], [], '', false); - $moduleUninstaller = $this->getMock('Magento\Setup\Model\ModuleUninstaller', [], [], '', false); - $moduleRegistryUninstaller = $this->getMock('Magento\Setup\Model\ModuleRegistryUninstaller', [], [], '', false); - $moduleEnabler = $this->getMock('Magento\Setup\Console\Command\ModuleEnableCommand', [], [], '', false); - $moduleDisabler = $this->getMock('Magento\Setup\Console\Command\ModuleDisableCommand', [], [], '', false); - - $updater = $this->getMock('Magento\Setup\Model\Updater', [], [], '', false); - $queue = $this->getMock('Magento\Setup\Model\Cron\Queue', [], [], '', false); + $upgradeCommand = $this->getMock(\Magento\Setup\Console\Command\UpgradeCommand::class, [], [], '', false); + $moduleUninstaller = $this->getMock(\Magento\Setup\Model\ModuleUninstaller::class, [], [], '', false); + $moduleRegistryUninstaller = + $this->getMock(\Magento\Setup\Model\ModuleRegistryUninstaller::class, [], [], '', false); + $moduleEnabler = $this->getMock(\Magento\Setup\Console\Command\ModuleEnableCommand::class, [], [], '', false); + $moduleDisabler = $this->getMock(\Magento\Setup\Console\Command\ModuleDisableCommand::class, [], [], '', false); + $updater = $this->getMock(\Magento\Setup\Model\Updater::class, [], [], '', false); + $queue = $this->getMock(\Magento\Setup\Model\Cron\Queue::class, [], [], '', false); $returnValueMap = [ - ['Magento\Setup\Model\Updater', $updater], - ['Magento\Setup\Model\Cron\Status', $status], - ['Magento\Setup\Console\Command\UpgradeCommand', $upgradeCommand], - ['Magento\Setup\Model\ObjectManagerProvider', $objectManagerProvider], - ['Magento\Setup\Model\ModuleUninstaller', $moduleUninstaller], - ['Magento\Setup\Model\ModuleRegistryUninstaller', $moduleRegistryUninstaller], - ['Magento\Setup\Console\Command\ModuleDisableCommand', $moduleDisabler], - ['Magento\Setup\Console\Command\ModuleEnableCommand', $moduleEnabler], - ['Magento\Setup\Model\Cron\Queue', $queue] + [\Magento\Setup\Model\Updater::class, $updater], + [\Magento\Setup\Model\Cron\Status::class, $status], + [\Magento\Setup\Console\Command\UpgradeCommand::class, $upgradeCommand], + [\Magento\Setup\Model\ObjectManagerProvider::class, $objectManagerProvider], + [\Magento\Setup\Model\ModuleUninstaller::class, $moduleUninstaller], + [\Magento\Setup\Model\ModuleRegistryUninstaller::class, $moduleRegistryUninstaller], + [\Magento\Setup\Console\Command\ModuleDisableCommand::class, $moduleDisabler], + [\Magento\Setup\Console\Command\ModuleEnableCommand::class, $moduleEnabler], + [\Magento\Setup\Model\Cron\Queue::class, $queue] ]; $serviceManager->expects($this->atLeastOnce()) @@ -65,23 +69,26 @@ class JobFactoryTest extends \PHPUnit_Framework_TestCase public function testUpgrade() { - $this->assertInstanceOf('Magento\Setup\Model\Cron\AbstractJob', $this->jobFactory->create('setup:upgrade', [])); + $this->assertInstanceOf( + \Magento\Setup\Model\Cron\AbstractJob::class, + $this->jobFactory->create('setup:upgrade', []) + ); } public function testRollback() { $valueMap = [ [ - 'Magento\Framework\App\State\CleanupFiles', - $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false) + \Magento\Framework\App\State\CleanupFiles::class, + $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, [], [], '', false) ], [ - 'Magento\Framework\App\Cache', - $this->getMock('Magento\Framework\App\Cache', [], [], '', false) + \Magento\Framework\App\Cache::class, + $this->getMock(\Magento\Framework\App\Cache::class, [], [], '', false) ], [ - 'Magento\Framework\Setup\BackupRollbackFactory', - $this->getMock('Magento\Framework\Setup\BackupRollbackFactory', [], [], '', false) + \Magento\Framework\Setup\BackupRollbackFactory::class, + $this->getMock(\Magento\Framework\Setup\BackupRollbackFactory::class, [], [], '', false) ], ]; $this->objectManager->expects($this->any()) @@ -89,7 +96,7 @@ class JobFactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValueMap($valueMap)); $this->assertInstanceOf( - 'Magento\Setup\Model\Cron\AbstractJob', + \Magento\Setup\Model\Cron\AbstractJob::class, $this->jobFactory->create('setup:rollback', []) ); } @@ -98,27 +105,27 @@ class JobFactoryTest extends \PHPUnit_Framework_TestCase { $valueMap = [ [ - 'Magento\Framework\Module\PackageInfoFactory', - $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false) + \Magento\Framework\Module\PackageInfoFactory::class, + $this->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false) ], [ - 'Magento\Framework\Composer\ComposerInformation', - $this->getMock('Magento\Framework\Composer\ComposerInformation', [], [], '', false) + \Magento\Framework\Composer\ComposerInformation::class, + $this->getMock(\Magento\Framework\Composer\ComposerInformation::class, [], [], '', false) ], [ - 'Magento\Theme\Model\Theme\ThemeUninstaller', - $this->getMock('Magento\Theme\Model\Theme\ThemeUninstaller', [], [], '', false) + \Magento\Theme\Model\Theme\ThemeUninstaller::class, + $this->getMock(\Magento\Theme\Model\Theme\ThemeUninstaller::class, [], [], '', false) ], [ - 'Magento\Theme\Model\Theme\ThemePackageInfo', - $this->getMock('Magento\Theme\Model\Theme\ThemePackageInfo', [], [], '', false) + \Magento\Theme\Model\Theme\ThemePackageInfo::class, + $this->getMock(\Magento\Theme\Model\Theme\ThemePackageInfo::class, [], [], '', false) ], ]; $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap($valueMap)); $this->assertInstanceOf( - 'Magento\Setup\Model\Cron\JobComponentUninstall', + \Magento\Setup\Model\Cron\JobComponentUninstall::class, $this->jobFactory->create('setup:component:uninstall', []) ); } @@ -136,8 +143,8 @@ class JobFactoryTest extends \PHPUnit_Framework_TestCase { $valueMap = [ [ - 'Magento\Framework\Module\PackageInfoFactory', - $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false) + \Magento\Framework\Module\PackageInfoFactory::class, + $this->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false) ], ]; $this->objectManager->expects($this->any()) @@ -145,7 +152,7 @@ class JobFactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValueMap($valueMap)); $this->assertInstanceOf( - 'Magento\Setup\Model\Cron\AbstractJob', + \Magento\Setup\Model\Cron\AbstractJob::class, $this->jobFactory->create('setup:module:disable', []) ); } @@ -154,8 +161,8 @@ class JobFactoryTest extends \PHPUnit_Framework_TestCase { $valueMap = [ [ - 'Magento\Framework\Module\PackageInfoFactory', - $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false) + \Magento\Framework\Module\PackageInfoFactory::class, + $this->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false) ], ]; $this->objectManager->expects($this->any()) @@ -163,7 +170,7 @@ class JobFactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValueMap($valueMap)); $this->assertInstanceOf( - 'Magento\Setup\Model\Cron\AbstractJob', + \Magento\Setup\Model\Cron\AbstractJob::class, $this->jobFactory->create('setup:module:enable', []) ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobModuleTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobModuleTest.php index 3d4536510ab8a095599d535ad1d98f39817f2dc1..c881e26e708e94470dc7db652f43cbe409a67901 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobModuleTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobModuleTest.php @@ -11,24 +11,26 @@ class JobModuleTest extends \PHPUnit_Framework_TestCase { public function testExecuteModuleDisable() { - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); - $cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = + $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class, [], '', false); + $cleanupFiles = $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, [], [], '', false); $cleanupFiles->expects($this->once())->method('clearCodeGeneratedFiles'); - $cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', false); + $cache = $this->getMock(\Magento\Framework\App\Cache::class, [], [], '', false); $cache->expects($this->once())->method('clean'); $valueMap = [ - ['Magento\Framework\Module\PackageInfoFactory'], - ['Magento\Framework\App\State\CleanupFiles', $cleanupFiles], - ['Magento\Framework\App\Cache', $cache], + [\Magento\Framework\Module\PackageInfoFactory::class], + [\Magento\Framework\App\State\CleanupFiles::class, $cleanupFiles], + [\Magento\Framework\App\Cache::class, $cache], ]; $objectManager->expects($this->atLeastOnce())->method('get')->will($this->returnValueMap($valueMap)); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); - $command = $this->getMock('Magento\Setup\Console\Command\ModuleDisableCommand', [], [], '', false); + $command = $this->getMock(\Magento\Setup\Console\Command\ModuleDisableCommand::class, [], [], '', false); $command->expects($this->once())->method('run'); - $status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); + $status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); $status->expects($this->atLeastOnce())->method('add'); - $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); + $output = + $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class, [], '', false); $params['components'][] = ['name' => 'vendor/module']; $jobModuleDisable = new JobModule( $command, @@ -43,24 +45,26 @@ class JobModuleTest extends \PHPUnit_Framework_TestCase public function testExecuteModuleEnable() { - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); - $cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = + $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class, [], '', false); + $cleanupFiles = $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, [], [], '', false); $cleanupFiles->expects($this->once())->method('clearCodeGeneratedFiles'); - $cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', false); + $cache = $this->getMock(\Magento\Framework\App\Cache::class, [], [], '', false); $cache->expects($this->once())->method('clean'); $valueMap = [ - ['Magento\Framework\Module\PackageInfoFactory'], - ['Magento\Framework\App\State\CleanupFiles', $cleanupFiles], - ['Magento\Framework\App\Cache', $cache], + [\Magento\Framework\Module\PackageInfoFactory::class], + [\Magento\Framework\App\State\CleanupFiles::class, $cleanupFiles], + [\Magento\Framework\App\Cache::class, $cache], ]; $objectManager->expects($this->atLeastOnce())->method('get')->will($this->returnValueMap($valueMap)); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); - $command = $this->getMock('Magento\Setup\Console\Command\ModuleEnableCommand', [], [], '', false); + $command = $this->getMock(\Magento\Setup\Console\Command\ModuleEnableCommand::class, [], [], '', false); $command->expects($this->once())->method('run'); - $status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); + $status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); $status->expects($this->atLeastOnce())->method('add'); - $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); + $output = + $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class, [], '', false); $params['components'][] = ['name' => 'vendor/module']; $jobModuleEnable = new JobModule( $command, diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobStaticRegenerateTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobStaticRegenerateTest.php index 8cf915b325f40def7fd604e63ecd89dde9e912f7..23027d4973d96bdb47e90af6289ab6374da99d15 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobStaticRegenerateTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobStaticRegenerateTest.php @@ -143,7 +143,7 @@ class JobStaticRegenerateTest extends \PHPUnit_Framework_TestCase */ protected function getJobStaticRegenerateMock($methods = null) { - return $this->getMock('Magento\Setup\Model\Cron\JobStaticRegenerate', $methods, [], '', false); + return $this->getMock(\Magento\Setup\Model\Cron\JobStaticRegenerate::class, $methods, [], '', false); } /** @@ -153,7 +153,7 @@ class JobStaticRegenerateTest extends \PHPUnit_Framework_TestCase */ protected function getFilesystemObjectMock($methods = null) { - return $this->getMock('Magento\Deploy\Model\Filesystem', $methods, [], '', false); + return $this->getMock(\Magento\Deploy\Model\Filesystem::class, $methods, [], '', false); } /** @@ -163,7 +163,7 @@ class JobStaticRegenerateTest extends \PHPUnit_Framework_TestCase */ protected function getStatucObjectMock($methods = null) { - return $this->getMock('Magento\Setup\Model\Cron\Status', $methods, [], '', false); + return $this->getMock(\Magento\Setup\Model\Cron\Status::class, $methods, [], '', false); } /** @@ -173,7 +173,7 @@ class JobStaticRegenerateTest extends \PHPUnit_Framework_TestCase */ protected function getCleanFilesObjectMock($methods = null) { - return $this->getMock('Magento\Framework\App\State\CleanupFiles', $methods, [], '', false); + return $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, $methods, [], '', false); } /** @@ -183,7 +183,7 @@ class JobStaticRegenerateTest extends \PHPUnit_Framework_TestCase */ protected function getCacheObjectMock($methods = null) { - return $this->getMock('Magento\Framework\App\State\CleanupFiles', $methods, [], '', false); + return $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, $methods, [], '', false); } /** @@ -193,7 +193,7 @@ class JobStaticRegenerateTest extends \PHPUnit_Framework_TestCase */ protected function getOutputObjectMock() { - return $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface'); + return $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class); } /** @@ -203,6 +203,6 @@ class JobStaticRegenerateTest extends \PHPUnit_Framework_TestCase */ protected function getModeObjectMock($methods = null) { - return $this->getMock('Magento\Deploy\Model\Mode', $methods, [], '', false); + return $this->getMock(\Magento\Deploy\Model\Mode::class, $methods, [], '', false); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php index 106e5adc0d367e73d12cf2dedce7058f49632f45..e21e344f7500b70f5dc8b34511339d6e168939f3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php @@ -11,13 +11,16 @@ class JobUpgradeTest extends \PHPUnit_Framework_TestCase { public function testExecute() { - $queue = $this->getMock('Magento\Setup\Model\Cron\Queue', [], [], '', false); - $command = $this->getMock('Magento\Setup\Console\Command\UpgradeCommand', [], [], '', false); + $queue = $this->getMock(\Magento\Setup\Model\Cron\Queue::class, [], [], '', false); + $command = $this->getMock(\Magento\Setup\Console\Command\UpgradeCommand::class, [], [], '', false); $command->expects($this->once())->method('run'); - $status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); - $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', ['get'], [], '', false); + $status = $this->getMock(\Magento\Setup\Model\Cron\Status::class, [], [], '', false); + $output = + $this->getMockForAbstractClass(\Symfony\Component\Console\Output\OutputInterface::class, [], '', false); + $objectManager = + $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class, [], '', false); + $objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, ['get'], [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); $jobUpgrade = new JobUpgrade( diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/ReaderTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/ReaderTest.php index 21f99bc57a761bd2724c096bdbea850ffc7bc30b..e081f85e0717a05c478d9f4b3d68c5d17a1a53df 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/ReaderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/ReaderTest.php @@ -26,9 +26,9 @@ class ReaderTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->directoryRead = $this->getMockForAbstractClass( - 'Magento\Framework\Filesystem\Directory\ReadInterface', + \Magento\Framework\Filesystem\Directory\ReadInterface::class, [], '', false diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/WriterTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/WriterTest.php index 4054acbed346bd0955872097972be3b8fbaf90d2..7cc4b195cf70cb3ae7fc28f1cfd0cb6bdbd09a86 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/WriterTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/WriterTest.php @@ -26,15 +26,15 @@ class WriterTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $directoryRead = $this->getMockForAbstractClass( - 'Magento\Framework\Filesystem\Directory\ReadInterface', + \Magento\Framework\Filesystem\Directory\ReadInterface::class, [], '', false ); $this->directoryWrite = $this->getMockForAbstractClass( - 'Magento\Framework\Filesystem\Directory\WriteInterface', + \Magento\Framework\Filesystem\Directory\WriteInterface::class, [], '', false diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/QueueTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/QueueTest.php index fd7bbee50d782c56275b3ee0c6e568b8616f05ce..3f45652400601c6ad9bb51a96a40dfaa4c238c58 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/QueueTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/QueueTest.php @@ -31,9 +31,9 @@ class QueueTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->reader = $this->getMock('Magento\Setup\Model\Cron\Queue\Reader', [], [], '', false); - $this->writer = $this->getMock('Magento\Setup\Model\Cron\Queue\Writer', [], [], '', false); - $this->jobFactory = $this->getMock('Magento\Setup\Model\Cron\JobFactory', [], [], '', false); + $this->reader = $this->getMock(\Magento\Setup\Model\Cron\Queue\Reader::class, [], [], '', false); + $this->writer = $this->getMock(\Magento\Setup\Model\Cron\Queue\Writer::class, [], [], '', false); + $this->jobFactory = $this->getMock(\Magento\Setup\Model\Cron\JobFactory::class, [], [], '', false); $this->queue = new Queue($this->reader, $this->writer, $this->jobFactory); } @@ -82,7 +82,7 @@ class QueueTest extends \PHPUnit_Framework_TestCase $this->reader->expects($this->once()) ->method('read') ->willReturn('{"jobs": [{"name": "job A", "params" : []}, {"name": "job B", "params" : []}]}'); - $job = $this->getMockForAbstractClass('Magento\Setup\Model\Cron\AbstractJob', [], '', false); + $job = $this->getMockForAbstractClass(\Magento\Setup\Model\Cron\AbstractJob::class, [], '', false); $this->jobFactory->expects($this->once())->method('create')->with('job A', [])->willReturn($job); $rawData = ['jobs' => [['name' => 'job B', 'params' => []]]]; $this->writer->expects($this->once())->method('write')->with(json_encode($rawData, JSON_PRETTY_PRINT)); @@ -94,7 +94,7 @@ class QueueTest extends \PHPUnit_Framework_TestCase $this->reader->expects($this->once()) ->method('read') ->willReturn('{"jobs": [{"name": "job A", "params" : []}]}'); - $job = $this->getMockForAbstractClass('Magento\Setup\Model\Cron\AbstractJob', [], '', false); + $job = $this->getMockForAbstractClass(\Magento\Setup\Model\Cron\AbstractJob::class, [], '', false); $this->jobFactory->expects($this->once())->method('create')->with('job A', [])->willReturn($job); $this->writer->expects($this->once())->method('write')->with(''); $this->assertEquals($job, $this->queue->popQueuedJob()); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/ReadinessCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/ReadinessCheckTest.php index 8501299c5f2217082e1602a4a133cb4ba94392c8..3dbfe334c54c9c5b7d27ca9fe4b0a90866e86741 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/ReadinessCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/ReadinessCheckTest.php @@ -47,8 +47,8 @@ class ReadinessCheckTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->dbValidator = $this->getMock(\Magento\Setup\Validator\DbValidator::class, [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $this->deploymentConfig->expects($this->once()) ->method('get') ->willReturn( @@ -59,10 +59,10 @@ class ReadinessCheckTest extends \PHPUnit_Framework_TestCase ConfigOptionsListConstants::KEY_PASSWORD => 'password' ] ); - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->write = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->write = $this->getMock(\Magento\Framework\Filesystem\Directory\Write::class, [], [], '', false); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($this->write); - $this->phpReadinessCheck = $this->getMock('Magento\Setup\Model\PhpReadinessCheck', [], [], '', false); + $this->phpReadinessCheck = $this->getMock(\Magento\Setup\Model\PhpReadinessCheck::class, [], [], '', false); $this->readinessCheck = new ReadinessCheck( $this->dbValidator, $this->deploymentConfig, diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/StatusTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/StatusTest.php index b39ebaf0b68b23726ac2d80191b2af9060166f20..4b88c0e56724d6a68e5cb33fdbfedd43f8cad977 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/StatusTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/StatusTest.php @@ -27,9 +27,9 @@ class StatusTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->varReaderWriter = $this->getMockForAbstractClass( - 'Magento\Framework\Filesystem\Directory\WriteInterface', + \Magento\Framework\Filesystem\Directory\WriteInterface::class, [], '', false diff --git a/setup/src/Magento/Setup/Test/Unit/Model/CronScriptReadinessCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/CronScriptReadinessCheckTest.php index 45ecfe94cb4544d62930addc9814a2c29735b291..52ad6b5e86f12954a734b3b04fe1ffda3ef6bac5 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/CronScriptReadinessCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/CronScriptReadinessCheckTest.php @@ -24,8 +24,8 @@ class CronScriptReadinessCheckTest extends \PHPUnit_Framework_TestCase public function setUp() { - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->read = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->read = $this->getMock(\Magento\Framework\Filesystem\Directory\Read::class, [], [], '', false); $filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($this->read); $this->cronScriptReadinessCheck = new CronScriptReadinessCheck($filesystem); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/DateTime/DateTimeProviderTest.php b/setup/src/Magento/Setup/Test/Unit/Model/DateTime/DateTimeProviderTest.php index 4d24e73a02e2685df5e56a6e6d05c0f1b5fc0bb7..9103124d268f15555a74b62fdefd6339434e3219 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/DateTime/DateTimeProviderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/DateTime/DateTimeProviderTest.php @@ -13,23 +13,28 @@ class DateTimeProviderTest extends \PHPUnit_Framework_TestCase { public function testGet() { - $dateTime = $this->getMock('\Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false); + $dateTime = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTime::class, [], [], '', false); /** @var TimezoneProvider|\PHPUnit_Framework_MockObject_MockObject $timeZoneProvider */ - $timeZoneProvider = $this->getMock('\Magento\Setup\Model\DateTime\TimezoneProvider', [], [], '', false); - $timeZone = $this->getMock('\Magento\Framework\Stdlib\DateTime\Timezone', [], [], '', false); + $timeZoneProvider = $this->getMock(\Magento\Setup\Model\DateTime\TimezoneProvider::class, [], [], '', false); + $timeZone = $this->getMock(\Magento\Framework\Stdlib\DateTime\Timezone::class, [], [], '', false); $timeZoneProvider->expects($this->any()) ->method('get') ->willReturn($timeZone); - $objectManager = $this->getMockForAbstractClass('\Magento\Framework\ObjectManagerInterface', [], '', false); + $objectManager = $this->getMockForAbstractClass( + \Magento\Framework\ObjectManagerInterface::class, + [], + '', + false + ); $objectManager->expects($this->once()) ->method('create') ->with( - 'Magento\Framework\Stdlib\DateTime\DateTime', + \Magento\Framework\Stdlib\DateTime\DateTime::class, ['localeDate' => $timeZone] ) ->willReturn($dateTime); /** @var ObjectManagerProvider|\PHPUnit_Framework_MockObject_MockObject $objectManagerProvider */ - $objectManagerProvider = $this->getMock('\Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->any()) ->method('get') ->willReturn($objectManager); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/DateTime/TimezoneProviderTest.php b/setup/src/Magento/Setup/Test/Unit/Model/DateTime/TimezoneProviderTest.php index 63c4df875e280d11c32e7e20aa75085c0ed94f19..7ffcfcd4fbada383c8be8f9ae933e7536cb402d8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/DateTime/TimezoneProviderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/DateTime/TimezoneProviderTest.php @@ -13,17 +13,22 @@ class TimezoneProviderTest extends \PHPUnit_Framework_TestCase { public function testGet() { - $timeZone = $this->getMock('\Magento\Framework\Stdlib\DateTime\Timezone', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('\Magento\Framework\ObjectManagerInterface', [], '', false); + $timeZone = $this->getMock(\Magento\Framework\Stdlib\DateTime\Timezone::class, [], [], '', false); + $objectManager = $this->getMockForAbstractClass( + \Magento\Framework\ObjectManagerInterface::class, + [], + '', + false + ); $objectManager->expects($this->once()) ->method('create') ->with( - 'Magento\Framework\Stdlib\DateTime\Timezone', + \Magento\Framework\Stdlib\DateTime\Timezone::class, ['scopeType' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT] ) ->willReturn($timeZone); /** @var ObjectManagerProvider|\PHPUnit_Framework_MockObject_MockObject $objectManagerProvider */ - $objectManagerProvider = $this->getMock('\Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->any()) ->method('get') ->willReturn($objectManager); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/DependencyReadinessCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/DependencyReadinessCheckTest.php index 0b4107f2a087631b86c067c3f1b57cf3402dcf83..78e7a1f9ee52f197759c69f7b5440cde2d330c95 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/DependencyReadinessCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/DependencyReadinessCheckTest.php @@ -36,15 +36,18 @@ class DependencyReadinessCheckTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->composerJsonFinder = $this->getMock('Magento\Framework\Composer\ComposerJsonFinder', [], [], '', false); + $this->composerJsonFinder = + $this->getMock(\Magento\Framework\Composer\ComposerJsonFinder::class, [], [], '', false); $this->composerJsonFinder->expects($this->once())->method('findComposerJson')->willReturn('composer.json'); - $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $this->directoryList = + $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); $this->directoryList->expects($this->exactly(2))->method('getPath')->willReturn('var'); - $this->reqUpdDryRunCommand = $this->getMock('Magento\Composer\RequireUpdateDryRunCommand', [], [], '', false); - $this->file = $this->getMock('Magento\Framework\Filesystem\Driver\File', [], [], '', false); + $this->reqUpdDryRunCommand = + $this->getMock(\Magento\Composer\RequireUpdateDryRunCommand::class, [], [], '', false); + $this->file = $this->getMock(\Magento\Framework\Filesystem\Driver\File::class, [], [], '', false); $this->file->expects($this->once())->method('copy')->with('composer.json', 'var/composer.json'); $composerAppFactory = $this->getMock( - 'Magento\Framework\Composer\MagentoComposerApplicationFactory', + \Magento\Framework\Composer\MagentoComposerApplicationFactory::class, [], [], '', diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Installer/ProgressFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Installer/ProgressFactoryTest.php index 94e78039a31fe21603ed2db10903e2b66ee69dde..095074b6af722fefe9c64e2bf08a959a7f8f54b4 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Installer/ProgressFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Installer/ProgressFactoryTest.php @@ -20,7 +20,7 @@ class ProgressFactoryTest extends \PHPUnit_Framework_TestCase '[Progress: 3 / 5] Installing C...', 'Output from C...', ]; - $logger = $this->getMock('Magento\Setup\Model\WebLogger', [], [], '', false); + $logger = $this->getMock(\Magento\Setup\Model\WebLogger::class, [], [], '', false); $logger->expects($this->once())->method('get')->will($this->returnValue($contents)); $progressFactory = new ProgressFactory(); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php index b8319fb158ba8d97c90adcb557c5520c26984a12..b683f536f2cf99b62809e66f6efd5d4d5839c6c7 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php @@ -8,103 +8,129 @@ namespace Magento\Setup\Test\Unit\Model; use \Magento\Setup\Model\InstallerFactory; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class InstallerFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $returnValueMap = [ + $serviceLocatorMock = $this->getMockForAbstractClass( + \Zend\ServiceManager\ServiceLocatorInterface::class, + ['get'] + ); + $serviceLocatorMock->expects($this->any())->method('get') + ->will($this->returnValueMap($this->getReturnValueMap())); + + $log = $this->getMockForAbstractClass(\Magento\Framework\Setup\LoggerInterface::class); + $resourceFactoryMock = $this->getMock(\Magento\Setup\Module\ResourceFactory::class, [], [], '', false); + $resourceFactoryMock + ->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->getMock( + \Magento\Framework\App\ResourceConnection::class, + [], + [], + '', + false + ))); + $installerFactory = new InstallerFactory($serviceLocatorMock, $resourceFactoryMock); + $installer = $installerFactory->create($log); + $this->assertInstanceOf(\Magento\Setup\Model\Installer::class, $installer); + } + + /** + * @return array + */ + private function getReturnValueMap() + { + return [ [ - 'Magento\Framework\Setup\FilePermissions', - $this->getMock('Magento\Framework\Setup\FilePermissions', [], [], '', false), + \Magento\Framework\Setup\FilePermissions::class, + $this->getMock(\Magento\Framework\Setup\FilePermissions::class, [], [], '', false), ], [ - 'Magento\Framework\App\DeploymentConfig\Writer', - $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false), + \Magento\Framework\App\DeploymentConfig\Writer::class, + $this->getMock(\Magento\Framework\App\DeploymentConfig\Writer::class, [], [], '', false), ], [ - 'Magento\Framework\App\DeploymentConfig\Reader', - $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false), + \Magento\Framework\App\DeploymentConfig\Reader::class, + $this->getMock(\Magento\Framework\App\DeploymentConfig\Reader::class, [], [], '', false), ], [ - 'Magento\Framework\App\DeploymentConfig', - $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false), + \Magento\Framework\App\DeploymentConfig::class, + $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false), ], [ - 'Magento\Framework\Module\ModuleList', - $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false), + \Magento\Framework\Module\ModuleList::class, + $this->getMock(\Magento\Framework\Module\ModuleList::class, [], [], '', false), ], [ - 'Magento\Framework\Module\ModuleList\Loader', - $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false), + \Magento\Framework\Module\ModuleList\Loader::class, + $this->getMock(\Magento\Framework\Module\ModuleList\Loader::class, [], [], '', false), ], [ - 'Magento\Setup\Model\AdminAccountFactory', - $this->getMock('Magento\Setup\Model\AdminAccountFactory', [], [], '', false), + \Magento\Setup\Model\AdminAccountFactory::class, + $this->getMock(\Magento\Setup\Model\AdminAccountFactory::class, [], [], '', false), ], [ - 'Magento\Setup\Module\ConnectionFactory', - $this->getMock('Magento\Setup\Module\ConnectionFactory', [], [], '', false), + \Magento\Setup\Module\ConnectionFactory::class, + $this->getMock(\Magento\Setup\Module\ConnectionFactory::class, [], [], '', false), ], [ - 'Magento\Framework\App\MaintenanceMode', - $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false), + \Magento\Framework\App\MaintenanceMode::class, + $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false), ], [ - 'Magento\Framework\Filesystem', - $this->getMock('Magento\Framework\Filesystem', [], [], '', false), + \Magento\Framework\Filesystem::class, + $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false), ], [ - 'Magento\Setup\Model\ObjectManagerProvider', - $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false), + \Magento\Setup\Model\ObjectManagerProvider::class, + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false), ], [ - 'Magento\Framework\Model\ResourceModel\Db\TransactionManager', - $this->getMock('Magento\Framework\Model\ResourceModel\Db\TransactionManager', [], [], '', false), + \Magento\Framework\Model\ResourceModel\Db\TransactionManager::class, + $this->getMock(\Magento\Framework\Model\ResourceModel\Db\TransactionManager::class, [], [], '', false), ], [ - 'Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', - $this->getMock('Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', [], [], '', false), + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, + $this->getMock( + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, + [], + [], + '', + false + ), ], [ - 'Magento\Setup\Model\ConfigModel', - $this->getMock('Magento\Setup\Model\ConfigModel', [], [], '', false), + \Magento\Setup\Model\ConfigModel::class, + $this->getMock(\Magento\Setup\Model\ConfigModel::class, [], [], '', false), ], [ - 'Magento\Framework\App\State\CleanupFiles', - $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false), + \Magento\Framework\App\State\CleanupFiles::class, + $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, [], [], '', false), ], [ - 'Magento\Setup\Validator\DbValidator', - $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false), + \Magento\Setup\Validator\DbValidator::class, + $this->getMock(\Magento\Setup\Validator\DbValidator::class, [], [], '', false), ], [ - 'Magento\Setup\Module\SetupFactory', - $this->getMock('Magento\Setup\Module\SetupFactory', [], [], '', false), + \Magento\Setup\Module\SetupFactory::class, + $this->getMock(\Magento\Setup\Module\SetupFactory::class, [], [], '', false), ], [ - 'Magento\Setup\Module\DataSetupFactory', - $this->getMock('Magento\Setup\Module\DataSetupFactory', [], [], '', false), + \Magento\Setup\Module\DataSetupFactory::class, + $this->getMock(\Magento\Setup\Module\DataSetupFactory::class, [], [], '', false), ], [ - 'Magento\Framework\Setup\SampleData\State', - $this->getMock('Magento\Framework\Setup\SampleData\State', [], [], '', false), + \Magento\Framework\Setup\SampleData\State::class, + $this->getMock(\Magento\Framework\Setup\SampleData\State::class, [], [], '', false), ], [ - 'Magento\Setup\Model\PhpReadinessCheck', - $this->getMock('Magento\Setup\Model\PhpReadinessCheck', [], [], '', false), + \Magento\Setup\Model\PhpReadinessCheck::class, + $this->getMock(\Magento\Setup\Model\PhpReadinessCheck::class, [], [], '', false), ], ]; - $serviceLocatorMock = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface', ['get']); - $serviceLocatorMock->expects($this->any())->method('get')->will($this->returnValueMap($returnValueMap)); - - $log = $this->getMockForAbstractClass('Magento\Framework\Setup\LoggerInterface'); - $resourceFactoryMock = $this->getMock('Magento\Setup\Module\ResourceFactory', [], [], '', false); - $resourceFactoryMock - ->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false))); - $installerFactory = new InstallerFactory($serviceLocatorMock, $resourceFactoryMock); - $installer = $installerFactory->create($log); - $this->assertInstanceOf('Magento\Setup\Model\Installer', $installer); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php index 760340f3cfb0172b1f16133011d8436b5215f29a..c40ef99d4e914d73ddf4c0f66e4dd9d87f33e0e7 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php @@ -155,36 +155,39 @@ class InstallerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filePermissions = $this->getMock('Magento\Framework\Setup\FilePermissions', [], [], '', false); - $this->configWriter = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); - $this->configReader = $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false); - $this->config = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->filePermissions = $this->getMock(\Magento\Framework\Setup\FilePermissions::class, [], [], '', false); + $this->configWriter = $this->getMock(\Magento\Framework\App\DeploymentConfig\Writer::class, [], [], '', false); + $this->configReader = $this->getMock(\Magento\Framework\App\DeploymentConfig\Reader::class, [], [], '', false); + $this->config = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); - $this->moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); + $this->moduleList = $this->getMockForAbstractClass(\Magento\Framework\Module\ModuleListInterface::class); $this->moduleList->expects($this->any())->method('getOne')->willReturn( ['setup_version' => '2.0.0'] ); $this->moduleList->expects($this->any())->method('getNames')->willReturn( ['Foo_One', 'Bar_Two'] ); - $this->moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); - $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); - $this->adminFactory = $this->getMock('Magento\Setup\Model\AdminAccountFactory', [], [], '', false); - $this->logger = $this->getMockForAbstractClass('Magento\Framework\Setup\LoggerInterface'); - $this->random = $this->getMock('Magento\Framework\Math\Random', [], [], '', false); - $this->connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); - $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); - $this->contextMock = $this->getMock('Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); - $this->configModel = $this->getMock('Magento\Setup\Model\ConfigModel', [], [], '', false); - $this->cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); - $this->dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false); - $this->setupFactory = $this->getMock('Magento\Setup\Module\SetupFactory', [], [], '', false); - $this->dataSetupFactory = $this->getMock('Magento\Setup\Module\DataSetupFactory', [], [], '', false); - $this->sampleDataState = $this->getMock('Magento\Framework\Setup\SampleData\State', [], [], '', false); - $this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); - $this->phpReadinessCheck = $this->getMock('Magento\Setup\Model\PhpReadinessCheck', [], [], '', false); + $this->moduleLoader = $this->getMock(\Magento\Framework\Module\ModuleList\Loader::class, [], [], '', false); + $this->directoryList = + $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); + $this->adminFactory = $this->getMock(\Magento\Setup\Model\AdminAccountFactory::class, [], [], '', false); + $this->logger = $this->getMockForAbstractClass(\Magento\Framework\Setup\LoggerInterface::class); + $this->random = $this->getMock(\Magento\Framework\Math\Random::class, [], [], '', false); + $this->connection = $this->getMockForAbstractClass(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, [], [], '', false); + $this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); + $this->contextMock = + $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); + $this->configModel = $this->getMock(\Magento\Setup\Model\ConfigModel::class, [], [], '', false); + $this->cleanupFiles = $this->getMock(\Magento\Framework\App\State\CleanupFiles::class, [], [], '', false); + $this->dbValidator = $this->getMock(\Magento\Setup\Validator\DbValidator::class, [], [], '', false); + $this->setupFactory = $this->getMock(\Magento\Setup\Module\SetupFactory::class, [], [], '', false); + $this->dataSetupFactory = $this->getMock(\Magento\Setup\Module\DataSetupFactory::class, [], [], '', false); + $this->sampleDataState = $this->getMock(\Magento\Framework\Setup\SampleData\State::class, [], [], '', false); + $this->componentRegistrar = + $this->getMock(\Magento\Framework\Component\ComponentRegistrar::class, [], [], '', false); + $this->phpReadinessCheck = $this->getMock(\Magento\Setup\Model\PhpReadinessCheck::class, [], [], '', false); $this->object = $this->createObject(); } @@ -198,11 +201,12 @@ class InstallerTest extends \PHPUnit_Framework_TestCase private function createObject($connectionFactory = false, $objectManagerProvider = false) { if (!$connectionFactory) { - $connectionFactory = $this->getMock('Magento\Setup\Module\ConnectionFactory', [], [], '', false); + $connectionFactory = $this->getMock(\Magento\Setup\Module\ConnectionFactory::class, [], [], '', false); $connectionFactory->expects($this->any())->method('create')->willReturn($this->connection); } if (!$objectManagerProvider) { - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); } @@ -250,41 +254,41 @@ class InstallerTest extends \PHPUnit_Framework_TestCase ); $allModules = ['Foo_One' => [], 'Bar_Two' => []]; $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules); - $setup = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false); - $table = $this->getMock('Magento\Framework\DB\Ddl\Table', [], [], '', false); - $connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); + $setup = $this->getMock(\Magento\Setup\Module\Setup::class, [], [], '', false); + $table = $this->getMock(\Magento\Framework\DB\Ddl\Table::class, [], [], '', false); + $connection = $this->getMockForAbstractClass(\Magento\Framework\DB\Adapter\AdapterInterface::class); $setup->expects($this->any())->method('getConnection')->willReturn($connection); $table->expects($this->any())->method('addColumn')->willReturn($table); $table->expects($this->any())->method('setComment')->willReturn($table); $table->expects($this->any())->method('addIndex')->willReturn($table); $connection->expects($this->any())->method('newTable')->willReturn($table); - $resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); + $resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); $this->contextMock->expects($this->any())->method('getResources')->willReturn($resource); $resource->expects($this->any())->method('getConnection')->will($this->returnValue($connection)); - $dataSetup = $this->getMock('Magento\Setup\Module\DataSetup', [], [], '', false); - $cacheManager = $this->getMock('Magento\Framework\App\Cache\Manager', [], [], '', false); + $dataSetup = $this->getMock(\Magento\Setup\Module\DataSetup::class, [], [], '', false); + $cacheManager = $this->getMock(\Magento\Framework\App\Cache\Manager::class, [], [], '', false); $cacheManager->expects($this->any())->method('getAvailableTypes')->willReturn(['foo', 'bar']); $cacheManager->expects($this->once())->method('setEnabled')->willReturn(['foo', 'bar']); $cacheManager->expects($this->any())->method('clean'); $appState = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Framework\App\State' + \Magento\Framework\App\State::class ); $this->setupFactory->expects($this->atLeastOnce())->method('create')->with($resource)->willReturn($setup); $this->dataSetupFactory->expects($this->atLeastOnce())->method('create')->willReturn($dataSetup); $this->objectManager->expects($this->any()) ->method('create') ->will($this->returnValueMap([ - ['Magento\Framework\App\Cache\Manager', [], $cacheManager], - ['Magento\Framework\App\State', [], $appState], + [\Magento\Framework\App\Cache\Manager::class, [], $cacheManager], + [\Magento\Framework\App\State::class, [], $appState], ])); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ - ['Magento\Framework\App\State', $appState], - ['Magento\Framework\App\Cache\Manager', $cacheManager] + [\Magento\Framework\App\State::class, $appState], + [\Magento\Framework\App\Cache\Manager::class, $cacheManager] ])); $this->adminFactory->expects($this->once())->method('create')->willReturn( - $this->getMock('Magento\Setup\Model\AdminAccount', [], [], '', false) + $this->getMock(\Magento\Setup\Model\AdminAccount::class, [], [], '', false) ); $this->sampleDataState->expects($this->once())->method('hasError')->willReturn(true); $this->phpReadinessCheck->expects($this->once())->method('checkPhpExtensions')->willReturn( @@ -412,7 +416,9 @@ class InstallerTest extends \PHPUnit_Framework_TestCase public function testUninstall() { $this->configReader->expects($this->once())->method('getFiles')->willReturn(['ConfigOne.php', 'ConfigTwo.php']); - $configDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $configDir = $this->getMockForAbstractClass( + \Magento\Framework\Filesystem\Directory\WriteInterface::class + ); $configDir ->expects($this->exactly(2)) ->method('getAbsolutePath') @@ -435,12 +441,12 @@ class InstallerTest extends \PHPUnit_Framework_TestCase ->expects($this->at(2)) ->method('log') ->with('No database connection defined - skipping database cleanup'); - $cacheManager = $this->getMock('Magento\Framework\App\Cache\Manager', [], [], '', false); + $cacheManager = $this->getMock(\Magento\Framework\App\Cache\Manager::class, [], [], '', false); $cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']); $cacheManager->expects($this->once())->method('clean'); $this->objectManager->expects($this->any()) ->method('get') - ->with('Magento\Framework\App\Cache\Manager') + ->with(\Magento\Framework\App\Cache\Manager::class) ->willReturn($cacheManager); $this->logger->expects($this->at(1))->method('log')->with('Cache cleared successfully'); $this->logger->expects($this->at(3))->method('log')->with('File system cleanup:'); @@ -499,13 +505,13 @@ class InstallerTest extends \PHPUnit_Framework_TestCase 'New_Module' => [], ]; - $cacheManager = $this->getMock('Magento\Framework\App\Cache\Manager', [], [], '', false); + $cacheManager = $this->getMock(\Magento\Framework\App\Cache\Manager::class, [], [], '', false); $cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']); $cacheManager->expects($this->once())->method('clean'); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ - ['Magento\Framework\App\Cache\Manager', $cacheManager] + [\Magento\Framework\App\Cache\Manager::class, $cacheManager] ])); $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/LicenseTest.php b/setup/src/Magento/Setup/Test/Unit/Model/LicenseTest.php index e85ddba28ee44e485a15f0fd906645bda92ab979..ed8f3efccb7a15c784076a3eb3e6b5a5b7f8a7aa 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/LicenseTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/LicenseTest.php @@ -22,8 +22,14 @@ class LicenseTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->directoryReadMock = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); - $this->filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->directoryReadMock = $this->getMock( + \Magento\Framework\Filesystem\Directory\Read::class, + [], + [], + '', + false + ); + $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->filesystemMock ->expects($this->once()) ->method('getDirectoryRead') diff --git a/setup/src/Magento/Setup/Test/Unit/Model/MarketplaceManagerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/MarketplaceManagerTest.php index ec708eb61325980cd115a051d8b03724660884f0..26b3d4d7447d3b912e854d1ca9bba22d931113f9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/MarketplaceManagerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/MarketplaceManagerTest.php @@ -721,7 +721,7 @@ class MarketplaceManagerTest extends \PHPUnit_Framework_TestCase */ protected function _getServiceLocatorMock() { - return $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface'); + return $this->getMockForAbstractClass(\Zend\ServiceManager\ServiceLocatorInterface::class); } /** @@ -732,7 +732,7 @@ class MarketplaceManagerTest extends \PHPUnit_Framework_TestCase */ protected function _getComposerInformationMock($methods = null) { - return $this->getMock('Magento\Framework\Composer\ComposerInformation', $methods, [], '', false); + return $this->getMock(\Magento\Framework\Composer\ComposerInformation::class, $methods, [], '', false); } /** @@ -743,7 +743,7 @@ class MarketplaceManagerTest extends \PHPUnit_Framework_TestCase */ protected function _getCurlClientMock($methods = null) { - return $this->getMock('Magento\Framework\HTTP\Client\Curl', $methods, [], '', false); + return $this->getMock(\Magento\Framework\HTTP\Client\Curl::class, $methods, [], '', false); } /** @@ -754,7 +754,7 @@ class MarketplaceManagerTest extends \PHPUnit_Framework_TestCase */ protected function _getFilesystemMock($methods = null) { - return $this->getMock('Magento\Framework\Filesystem', $methods, [], '', false); + return $this->getMock(\Magento\Framework\Filesystem::class, $methods, [], '', false); } /** @@ -764,7 +764,7 @@ class MarketplaceManagerTest extends \PHPUnit_Framework_TestCase */ protected function _getDirectoryMock() { - return $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + return $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); } /** @@ -775,6 +775,6 @@ class MarketplaceManagerTest extends \PHPUnit_Framework_TestCase */ protected function _getMarketplaceManagerMock($methods = null, $arguments = []) { - return $this->getMock('Magento\Setup\Model\MarketplaceManager', $methods, $arguments, '', false); + return $this->getMock(\Magento\Setup\Model\MarketplaceManager::class, $methods, $arguments, '', false); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ModuleRegistryUninstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ModuleRegistryUninstallerTest.php index 2cc88c0358f406fec3388c3503db3e9b0b1ec785..f5054ce24f1c4246992f39c966c6550bdd17bf73 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ModuleRegistryUninstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ModuleRegistryUninstallerTest.php @@ -43,13 +43,13 @@ class ModuleRegistryUninstallerTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->writer = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); - $this->loader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); - $this->dataSetup = $this->getMock('Magento\Setup\Module\DataSetup', [], [], '', false); - $dataSetupFactory = $this->getMock('Magento\Setup\Module\DataSetupFactory', [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->writer = $this->getMock(\Magento\Framework\App\DeploymentConfig\Writer::class, [], [], '', false); + $this->loader = $this->getMock(\Magento\Framework\Module\ModuleList\Loader::class, [], [], '', false); + $this->dataSetup = $this->getMock(\Magento\Setup\Module\DataSetup::class, [], [], '', false); + $dataSetupFactory = $this->getMock(\Magento\Setup\Module\DataSetupFactory::class, [], [], '', false); $dataSetupFactory->expects($this->any())->method('create')->willReturn($this->dataSetup); - $this->output = $this->getMock('Symfony\Component\Console\Output\OutputInterface', [], [], '', false); + $this->output = $this->getMock(\Symfony\Component\Console\Output\OutputInterface::class, [], [], '', false); $this->moduleRegistryUninstaller = new ModuleRegistryUninstaller( $dataSetupFactory, $this->deploymentConfig, diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusFactoryTest.php index deac722a17cd8dadd9597cddd5297a9ed876e7aa..c756a5362e24feec1c94d2f5670fdb68a3a45e17 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusFactoryTest.php @@ -27,9 +27,15 @@ class ModuleStatusFactoryTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $this->objectManagerProvider = $this->getMock( + \Magento\Setup\Model\ObjectManagerProvider::class, + [], + [], + '', + false + ); $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false @@ -41,7 +47,7 @@ class ModuleStatusFactoryTest extends \PHPUnit_Framework_TestCase $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager); $this->objectManager->expects($this->once()) ->method('get') - ->with('Magento\Framework\Module\Status'); + ->with(\Magento\Framework\Module\Status::class); $this->moduleStatusFactory = new ModuleStatusFactory($this->objectManagerProvider); $this->moduleStatusFactory->create(); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusTest.php index 15e5c49f84bd105d7bfc5309651c9c2e4daebea2..83930eb039dfb9e56c2a64fc69d381a348772e6e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusTest.php @@ -35,14 +35,15 @@ class ModuleStatusTest extends \PHPUnit_Framework_TestCase */ private $objectManagerProvider; - public function setUp() { - $this->moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); - $this->dependencyChecker = $this->getMock('Magento\Framework\Module\DependencyChecker', [], [], '', false); - $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); - $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $this->moduleLoader = $this->getMock(\Magento\Framework\Module\ModuleList\Loader::class, [], [], '', false); + $this->dependencyChecker = + $this->getMock(\Magento\Framework\Module\DependencyChecker::class, [], [], '', false); + $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); + $this->objectManagerProvider = + $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager); $this->objectManager->expects($this->once())->method('get')->willReturn($this->dependencyChecker); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ModuleUninstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ModuleUninstallerTest.php index bc802385368eec0ed871155971d5e9252f58d47f..e9248f7bb68eee00bfe08c5e852e376903835243 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ModuleUninstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ModuleUninstallerTest.php @@ -7,6 +7,9 @@ namespace Magento\Setup\Test\Unit\Model; use Magento\Setup\Model\ModuleUninstaller; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ModuleUninstallerTest extends \PHPUnit_Framework_TestCase { /** @@ -47,26 +50,26 @@ class ModuleUninstallerTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->moduleRegistryUninstaller = $this->getMock( - 'Magento\Setup\Model\ModuleRegistryUninstaller', + \Magento\Setup\Model\ModuleRegistryUninstaller::class, [], [], '', false ); $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false ); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager); - $this->remove = $this->getMock('Magento\Framework\Composer\Remove', [], [], '', false); - $this->collector = $this->getMock('Magento\Setup\Model\UninstallCollector', [], [], '', false); + $this->remove = $this->getMock(\Magento\Framework\Composer\Remove::class, [], [], '', false); + $this->collector = $this->getMock(\Magento\Setup\Model\UninstallCollector::class, [], [], '', false); - $this->setup = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false); - $setupFactory = $this->getMock('Magento\Setup\Module\SetupFactory', [], [], '', false); + $this->setup = $this->getMock(\Magento\Setup\Module\Setup::class, [], [], '', false); + $setupFactory = $this->getMock(\Magento\Setup\Module\SetupFactory::class, [], [], '', false); $setupFactory->expects($this->any())->method('create')->willReturn($this->setup); $this->uninstaller = new ModuleUninstaller( @@ -77,28 +80,28 @@ class ModuleUninstallerTest extends \PHPUnit_Framework_TestCase $this->moduleRegistryUninstaller ); - $this->output = $this->getMock('Symfony\Component\Console\Output\OutputInterface', [], [], '', false); + $this->output = $this->getMock(\Symfony\Component\Console\Output\OutputInterface::class, [], [], '', false); } public function testUninstallRemoveData() { $this->moduleRegistryUninstaller->expects($this->never())->method($this->anything()); - $uninstall = $this->getMockForAbstractClass('Magento\Framework\Setup\UninstallInterface', [], '', false); + $uninstall = $this->getMockForAbstractClass(\Magento\Framework\Setup\UninstallInterface::class, [], '', false); $uninstall->expects($this->atLeastOnce()) ->method('uninstall') - ->with($this->setup, $this->isInstanceOf('Magento\Setup\Model\ModuleContext')); + ->with($this->setup, $this->isInstanceOf(\Magento\Setup\Model\ModuleContext::class)); $this->collector->expects($this->once()) ->method('collectUninstall') ->willReturn(['moduleA' => $uninstall, 'moduleB' => $uninstall]); - $resource = $this->getMock('Magento\Framework\Module\ModuleResource', [], [], '', false); + $resource = $this->getMock(\Magento\Framework\Module\ModuleResource::class, [], [], '', false); $resource->expects($this->atLeastOnce())->method('getDbVersion')->willReturn('1.0'); $this->output->expects($this->atLeastOnce())->method('writeln'); $this->objectManager->expects($this->once()) ->method('get') - ->with('Magento\Framework\Module\ModuleResource') + ->with(\Magento\Framework\Module\ModuleResource::class) ->willReturn($resource); $this->uninstaller->uninstallData($this->output, ['moduleA', 'moduleB']); } @@ -107,13 +110,13 @@ class ModuleUninstallerTest extends \PHPUnit_Framework_TestCase { $this->moduleRegistryUninstaller->expects($this->never())->method($this->anything()); $this->output->expects($this->once())->method('writeln'); - $packageInfoFactory = $this->getMock('Magento\Framework\Module\PackageInfoFactory', [], [], '', false); - $packageInfo = $this->getMock('Magento\Framework\Module\PackageInfo', [], [], '', false); + $packageInfoFactory = $this->getMock(\Magento\Framework\Module\PackageInfoFactory::class, [], [], '', false); + $packageInfo = $this->getMock(\Magento\Framework\Module\PackageInfo::class, [], [], '', false); $packageInfo->expects($this->atLeastOnce())->method('getPackageName'); $packageInfoFactory->expects($this->once())->method('create')->willReturn($packageInfo); $this->objectManager->expects($this->once()) ->method('get') - ->with('Magento\Framework\Module\PackageInfoFactory') + ->with(\Magento\Framework\Module\PackageInfoFactory::class) ->willReturn($packageInfoFactory); $this->remove->expects($this->once())->method('remove'); $this->uninstaller->uninstallCode($this->output, ['moduleA', 'moduleB']); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/NavigationTest.php b/setup/src/Magento/Setup/Test/Unit/Model/NavigationTest.php index 8e81e498daf7aab46f55d2b7679eadd536e5431f..eea8d68ae943a4e2fd7b29c0222feb73b67d81ea 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/NavigationTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/NavigationTest.php @@ -28,7 +28,7 @@ class NavigationTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->serviceLocatorMock = - $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface', ['get']); + $this->getMockForAbstractClass(\Zend\ServiceManager\ServiceLocatorInterface::class, ['get']); $this->serviceLocatorMock ->expects($this->exactly(2)) ->method('get') @@ -49,7 +49,7 @@ class NavigationTest extends \PHPUnit_Framework_TestCase ] ])); $this->deploymentConfig = $this->getMock( - 'Magento\Framework\App\DeploymentConfig', + \Magento\Framework\App\DeploymentConfig::class, [], [], '', diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php index 256f7b25921c021378f024a6cbc23ee1e9280de1..971ba13bade7f1ebca4d919d17aeeb428461c867 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php @@ -32,9 +32,9 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->composerInfo = $this->getMock('Magento\Framework\Composer\ComposerInformation', [], [], '', false); - $this->phpInfo = $this->getMock('Magento\Setup\Model\PhpInformation', [], [], '', false); - $this->versionParser = $this->getMock('Composer\Package\Version\VersionParser', [], [], '', false); + $this->composerInfo = $this->getMock(\Magento\Framework\Composer\ComposerInformation::class, [], [], '', false); + $this->phpInfo = $this->getMock(\Magento\Setup\Model\PhpInformation::class, [], [], '', false); + $this->versionParser = $this->getMock(\Composer\Package\Version\VersionParser::class, [], [], '', false); $this->phpReadinessCheck = new PhpReadinessCheck($this->composerInfo, $this->phpInfo, $this->versionParser); } @@ -57,7 +57,7 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase { $this->composerInfo->expects($this->once())->method('getRequiredPhpVersion')->willReturn('1.0'); $multipleConstraints = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false @@ -68,7 +68,7 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase ->willThrowException(new \UnexpectedValueException()); $this->versionParser->expects($this->at(2))->method('normalize')->willReturn('1.0'); $currentPhpVersion = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false @@ -89,7 +89,7 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase { $this->composerInfo->expects($this->once())->method('getRequiredPhpVersion')->willReturn('1.0'); $multipleConstraints = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false @@ -100,7 +100,7 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase ->willThrowException(new \UnexpectedValueException()); $this->versionParser->expects($this->at(2))->method('normalize')->willReturn('1.0'); $currentPhpVersion = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false @@ -120,7 +120,7 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase private function setUpNoPrettyVersionParser() { $multipleConstraints = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false @@ -128,7 +128,7 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase $this->versionParser->expects($this->at(0))->method('parseConstraints')->willReturn($multipleConstraints); $this->versionParser->expects($this->at(1))->method('normalize')->willReturn('1.0'); $currentPhpVersion = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false @@ -156,7 +156,7 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase { $this->composerInfo->expects($this->once())->method('getRequiredPhpVersion')->willReturn('1.0'); $multipleConstraints = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false @@ -164,7 +164,7 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase $this->versionParser->expects($this->at(0))->method('parseConstraints')->willReturn($multipleConstraints); $this->versionParser->expects($this->at(1))->method('normalize')->willReturn('1.0'); $currentPhpVersion = $this->getMockForAbstractClass( - 'Composer\Semver\Constraint\ConstraintInterface', + \Composer\Semver\Constraint\ConstraintInterface::class, [], '', false diff --git a/setup/src/Magento/Setup/Test/Unit/Model/SystemPackageTest.php b/setup/src/Magento/Setup/Test/Unit/Model/SystemPackageTest.php index b9dde9b9176abde96408a05ab86af541e291e87d..e0ef3ae579664af52def117d52caa30a8cdc96c1 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/SystemPackageTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/SystemPackageTest.php @@ -53,7 +53,7 @@ class SystemPackageTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->composerAppFactory = $this->getMock( - 'Magento\Framework\Composer\MagentoComposerApplicationFactory', + \Magento\Framework\Composer\MagentoComposerApplicationFactory::class, [], [], '', @@ -61,19 +61,20 @@ class SystemPackageTest extends \PHPUnit_Framework_TestCase ); $this->infoCommand = $this->getMock( - '\Magento\Composer\InfoCommand', + \Magento\Composer\InfoCommand::class, [], [], '', false ); - $this->magentoComposerApp = $this->getMock('Magento\Composer\MagentoComposerApplication', [], [], '', false); - $this->locker = $this->getMock('Composer\Package\Locker', [], [], '', false); - $this->repository = $this->getMock('Composer\Repository\ArrayRepository', [], [], '', false); - $this->composer = $this->getMock('Composer\Composer', [], [], '', false); + $this->magentoComposerApp = + $this->getMock(\Magento\Composer\MagentoComposerApplication::class, [], [], '', false); + $this->locker = $this->getMock(\Composer\Package\Locker::class, [], [], '', false); + $this->repository = $this->getMock(\Composer\Repository\ArrayRepository::class, [], [], '', false); + $this->composer = $this->getMock(\Composer\Composer::class, [], [], '', false); $this->composerInformation = $this->getMock( - 'Magento\Framework\Composer\ComposerInformation', + \Magento\Framework\Composer\ComposerInformation::class, [], [], '', @@ -83,9 +84,9 @@ class SystemPackageTest extends \PHPUnit_Framework_TestCase public function testGetPackageVersions() { - $communityPackage = $this->getMock('\Composer\Package\Package', [], [], '', false); + $communityPackage = $this->getMock(\Composer\Package\Package::class, [], [], '', false); $communityPackage->expects($this->once())->method('getName')->willReturn('magento/product-community-edition'); - $enterprisePackage = $this->getMock('\Composer\Package\Package', [], [], '', false); + $enterprisePackage = $this->getMock(\Composer\Package\Package::class, [], [], '', false); $enterprisePackage->expects($this->once())->method('getName')->willReturn('magento/product-enterprise-edition'); $this->composerInformation->expects($this->any())->method('isSystemPackage')->willReturn(true); $this->composerInformation->expects($this->once())->method('isPackageInComposerJson')->willReturn(true); @@ -181,7 +182,7 @@ class SystemPackageTest extends \PHPUnit_Framework_TestCase */ public function testGetPackageVersionGitCloned() { - $package = $this->getMock('\Composer\Package\Package', [], [], '', false); + $package = $this->getMock(\Composer\Package\Package::class, [], [], '', false); $this->repository ->expects($this->once()) ->method('getPackages') @@ -210,8 +211,8 @@ class SystemPackageTest extends \PHPUnit_Framework_TestCase */ public function testGetPackageVersionsFailed() { - $communityPackage = $this->getMock('\Composer\Package\Package', [], [], '', false); - $enterprisePackage = $this->getMock('\Composer\Package\Package', [], [], '', false); + $communityPackage = $this->getMock(\Composer\Package\Package::class, [], [], '', false); + $enterprisePackage = $this->getMock(\Composer\Package\Package::class, [], [], '', false); $communityPackage->expects($this->once())->method('getName')->willReturn('magento/product-community-edition'); $enterprisePackage->expects($this->once())->method('getName')->willReturn('magento/product-enterprise-edition'); @@ -262,8 +263,8 @@ class SystemPackageTest extends \PHPUnit_Framework_TestCase ->method('run') ->with('magento/product-enterprise-edition') ->willReturn(['available_versions' => ['1.0.0', '1.0.1', '1.0.2']]); - $require = $this->getMock('\Composer\Package\Link', [], [], '', false); - $constraintMock = $this->getMock('\Composer\Semver\Constraint\Constraint', [], [], '', false); + $require = $this->getMock(\Composer\Package\Link::class, [], [], '', false); + $constraintMock = $this->getMock(\Composer\Semver\Constraint\Constraint::class, [], [], '', false); $constraintMock->expects($this->any())->method('getPrettyString') ->willReturn('1.0.1'); $require->expects($this->any()) diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ThemeDependencyCheckerFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ThemeDependencyCheckerFactoryTest.php index 7074b8d0645b3d049f9aa142f9b13e88b21e2278..a26d5eb0f8867a6974dfe934aa30d59666bff8b8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ThemeDependencyCheckerFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ThemeDependencyCheckerFactoryTest.php @@ -27,9 +27,15 @@ class ThemeDependencyCheckerFactoryTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $this->objectManagerProvider = $this->getMock( + \Magento\Setup\Model\ObjectManagerProvider::class, + [], + [], + '', + false + ); $this->objectManager = $this->getMockForAbstractClass( - 'Magento\Framework\ObjectManagerInterface', + \Magento\Framework\ObjectManagerInterface::class, [], '', false @@ -41,7 +47,7 @@ class ThemeDependencyCheckerFactoryTest extends \PHPUnit_Framework_TestCase $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager); $this->objectManager->expects($this->once()) ->method('get') - ->with('Magento\Theme\Model\Theme\ThemeDependencyChecker'); + ->with(\Magento\Theme\Model\Theme\ThemeDependencyChecker::class); $this->themeDependencyCheckerFactory = new ThemeDependencyCheckerFactory($this->objectManagerProvider); $this->themeDependencyCheckerFactory->create(); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/UninstallCollectorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/UninstallCollectorTest.php index d4272da88fb95bee6711ecd3c36bf4eb178ef7cf..3cb04351f04385e0d1e8c14d607807b3b5c9cd82 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/UninstallCollectorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/UninstallCollectorTest.php @@ -24,27 +24,26 @@ class UninstallCollectorTest extends \PHPUnit_Framework_TestCase */ private $result; - public function setUp() { - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); + $objectManager = + $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class, [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); - $setup = $this->getMock('Magento\Setup\Module\DataSetup', [], [], '', false); + $setup = $this->getMock(\Magento\Setup\Module\DataSetup::class, [], [], '', false); $this->adapterInterface = $this->getMockForAbstractClass( - 'Magento\Framework\DB\Adapter\AdapterInterface', + \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false ); - $select = $this->getMock('Magento\Framework\DB\Select', ['from'], [], '', false); + $select = $this->getMock(\Magento\Framework\DB\Select::class, ['from'], [], '', false); $this->adapterInterface->expects($this->once())->method('select')->willReturn($select); $setup->expects($this->exactly(2))->method('getConnection')->willReturn($this->adapterInterface); - $this->result = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->result = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); $select->expects($this->once())->method('from')->willReturn($this->result); - $uninstallA = 'Uninstall Class A'; $uninstallB = 'Uninstall Class B'; $objectManager->expects($this->any()) @@ -55,7 +54,7 @@ class UninstallCollectorTest extends \PHPUnit_Framework_TestCase ['Magento\B\Setup\Uninstall', [], $uninstallB], ]) ); - $setupFactory = $this->getMock('Magento\Setup\Module\DataSetupFactory', [], [], '', false); + $setupFactory = $this->getMock(\Magento\Setup\Module\DataSetupFactory::class, [], [], '', false); $setupFactory->expects($this->once())->method('create')->willReturn($setup); $this->collector = new UninstallCollector($objectManagerProvider, $setupFactory); @@ -99,10 +98,10 @@ namespace Magento\Setup\Model; */ function is_subclass_of($obj, $className) { - if ($obj == 'Uninstall Class A' && $className == 'Magento\Framework\Setup\UninstallInterface') { + if ($obj == 'Uninstall Class A' && $className == \Magento\Framework\Setup\UninstallInterface::class) { return true; } - if ($obj == 'Uninstall Class B' && $className == 'Magento\Framework\Setup\UninstallInterface') { + if ($obj == 'Uninstall Class B' && $className == \Magento\Framework\Setup\UninstallInterface::class) { return true; } return false; diff --git a/setup/src/Magento/Setup/Test/Unit/Model/UninstallDependencyCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/UninstallDependencyCheckTest.php index 2b643bd4eb2cadd608af523755e03a60eb1f8bed..3599fd549ef61034dc82c66ea79b514cfa93369c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/UninstallDependencyCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/UninstallDependencyCheckTest.php @@ -37,23 +37,23 @@ class UninstallDependencyCheckTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->composerInfo = $this->getMock('Magento\Framework\Composer\ComposerInformation', [], [], '', false); + $this->composerInfo = $this->getMock(\Magento\Framework\Composer\ComposerInformation::class, [], [], '', false); $this->packageDependencyChecker = $this->getMock( - 'Magento\Framework\Composer\DependencyChecker', + \Magento\Framework\Composer\DependencyChecker::class, [], [], '', false ); $this->themeDependencyChecker = $this->getMock( - 'Magento\Theme\Model\Theme\ThemeDependencyChecker', + \Magento\Theme\Model\Theme\ThemeDependencyChecker::class, [], [], '', false ); $this->themeDependencyCheckerFactory = $this->getMock( - 'Magento\Setup\Model\ThemeDependencyCheckerFactory', + \Magento\Setup\Model\ThemeDependencyCheckerFactory::class, [], [], '', diff --git a/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTest.php b/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTest.php index df144e2c7d527ba9d7e06c55e1319e8c84937735..6446c9959e4962c0dd333770415386f160dbc7c7 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTest.php @@ -13,7 +13,7 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase { public function testCreateUpdaterTaskUpdate() { - $queue = $this->getMock('Magento\Setup\Model\Cron\Queue', [], [], '', false); + $queue = $this->getMock(\Magento\Setup\Model\Cron\Queue::class, [], [], '', false); $queue->expects($this->once()) ->method('addJobs') ->with( @@ -33,7 +33,7 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase public function testCreateUpdaterTaskUninstall() { - $queue = $this->getMock('Magento\Setup\Model\Cron\Queue', [], [], '', false); + $queue = $this->getMock(\Magento\Setup\Model\Cron\Queue::class, [], [], '', false); $queue->expects($this->once()) ->method('addJobs') ->with( diff --git a/setup/src/Magento/Setup/Test/Unit/Model/WebLoggerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/WebLoggerTest.php index 38f262bf2a93ab4d9b4895de9f14965f87487124..dd1cc93314cd67da4e6dcbca21ad3a77d29cbe23 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/WebLoggerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/WebLoggerTest.php @@ -34,23 +34,29 @@ class WebLoggerTest extends \PHPUnit_Framework_TestCase { self::$log = ''; - $this->directoryWriteMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $this->directoryWriteMock = $this->getMock( + \Magento\Framework\Filesystem\Directory\Write::class, + [], + [], + '', + false + ); $this->directoryWriteMock ->expects($this->any()) ->method('readFile') ->with('install.log') - ->will($this->returnCallback(['Magento\Setup\Test\Unit\Model\WebLoggerTest', 'readLog'])); + ->will($this->returnCallback([\Magento\Setup\Test\Unit\Model\WebLoggerTest::class, 'readLog'])); $this->directoryWriteMock ->expects($this->any()) ->method('writeFile') ->with('install.log') - ->will($this->returnCallback(['Magento\Setup\Test\Unit\Model\WebLoggerTest', 'writeToLog'])); + ->will($this->returnCallback([\Magento\Setup\Test\Unit\Model\WebLoggerTest::class, 'writeToLog'])); $this->directoryWriteMock ->expects($this->any()) ->method('isExist') - ->will($this->returnCallback(['Magento\Setup\Test\Unit\Model\WebLoggerTest', 'isExist'])); + ->will($this->returnCallback([\Magento\Setup\Test\Unit\Model\WebLoggerTest::class, 'isExist'])); - $this->filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $this->filesystemMock ->expects($this->once()) ->method('getDirectoryWrite') @@ -62,11 +68,11 @@ class WebLoggerTest extends \PHPUnit_Framework_TestCase public function testConstructorLogFileSpecified() { $logFile = 'custom.log'; - $directoryWriteMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $directoryWriteMock = $this->getMock(\Magento\Framework\Filesystem\Directory\Write::class, [], [], '', false); $directoryWriteMock->expects($this->once())->method('readFile')->with($logFile); $directoryWriteMock->expects($this->once())->method('writeFile')->with($logFile); - $filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); $filesystemMock ->expects($this->once()) ->method('getDirectoryWrite') @@ -166,7 +172,7 @@ class WebLoggerTest extends \PHPUnit_Framework_TestCase $this->directoryWriteMock ->expects($this->once()) ->method('delete') - ->will($this->returnCallback(['Magento\Setup\Test\Unit\Model\WebLoggerTest', 'deleteLog'])); + ->will($this->returnCallback([\Magento\Setup\Test\Unit\Model\WebLoggerTest::class, 'deleteLog'])); $this->webLogger->log('Message1'); $this->assertEquals('<span class="text-info">Message1</span><br>', self::$log); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php index 1344810b9a476ce0531a275c37cbe15afa9a6436..caca5509d1e14ee4500803d05275d543692393f1 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php @@ -18,9 +18,9 @@ class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $random = $this->getMock('Magento\Framework\Math\Random', [], [], '', false); + $random = $this->getMock(\Magento\Framework\Math\Random::class, [], [], '', false); $random->expects($this->any())->method('getRandomString')->willReturn('key'); - $deployConfig= $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $deployConfig= $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); $deployConfig->expects($this->any())->method('isAvailable')->willReturn(false); $this->configGeneratorObject = new ConfigGenerator($random, $deployConfig); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/ConnectionFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/ConnectionFactoryTest.php index 69be0030e5740d4d6623569f5ccba70e590c0c4d..8b887ab7ba0025e88e92c1eec95956a9883fae36 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/ConnectionFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/ConnectionFactoryTest.php @@ -17,7 +17,10 @@ class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $serviceLocatorMock = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface', ['get']); + $serviceLocatorMock = $this->getMockForAbstractClass( + \Zend\ServiceManager\ServiceLocatorInterface::class, + ['get'] + ); $this->connectionFactory = new ConnectionFactory($serviceLocatorMock); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/DataSetupFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/DataSetupFactoryTest.php index 43678da1dec8da60c6a2fa655c5ac9722501f4fa..5688d7d63090e3498033a9ca8c7fcd1776dfa202 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/DataSetupFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/DataSetupFactoryTest.php @@ -11,22 +11,27 @@ class DataSetupFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); - $context = $this->getMock('Magento\Framework\Module\Setup\Context', [], [], '', false); + $resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $context = $this->getMock(\Magento\Framework\Module\Setup\Context::class, [], [], '', false); $context->expects($this->once())->method('getEventManager'); $context->expects($this->once())->method('getLogger'); $context->expects($this->once())->method('getMigrationFactory'); $context->expects($this->once())->method('getResourceModel')->willReturn($resource); $context->expects($this->once())->method('getFilesystem')->willReturn($filesystem); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); + $objectManager = $this->getMockForAbstractClass( + \Magento\Framework\ObjectManagerInterface::class, + [], + '', + false + ); $objectManager->expects($this->once()) ->method('get') - ->with('Magento\Framework\Module\Setup\Context') + ->with(\Magento\Framework\Module\Setup\Context::class) ->willReturn($context); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); $factory = new DataSetupFactory($objectManagerProvider); - $this->assertInstanceOf('Magento\Setup\Module\DataSetup', $factory->create()); + $this->assertInstanceOf(\Magento\Setup\Module\DataSetup::class, $factory->create()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/CodeTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/CodeTest.php index 25fd09230ec31a544446766dc8300d2d8861710e..2c71f24109f54764c7d9db4e9ea01de68308be8a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/CodeTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/CodeTest.php @@ -17,7 +17,7 @@ class CodeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->parser = $objectManagerHelper->getObject('Magento\Setup\Module\Dependency\Parser\Code'); + $this->parser = $objectManagerHelper->getObject(\Magento\Setup\Module\Dependency\Parser\Code::class); } /** diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Composer/JsonTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Composer/JsonTest.php index 62141b71885cd60b06492de8c7057c9245caece1..35543599334490804311828d79001b96e8417980 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Composer/JsonTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Composer/JsonTest.php @@ -17,7 +17,7 @@ class JsonTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->parser = $objectManagerHelper->getObject('Magento\Setup\Module\Dependency\Parser\Composer\Json'); + $this->parser = $objectManagerHelper->getObject(\Magento\Setup\Module\Dependency\Parser\Composer\Json::class); } /** diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Config/XmlTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Config/XmlTest.php index 1da1efc2c26e1d72971273a8ec05e9296de0d812..eb4b0adc635912d4c8b6408facad69115925d295 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Config/XmlTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Config/XmlTest.php @@ -17,7 +17,7 @@ class XmlTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->parser = $objectManagerHelper->getObject('Magento\Setup\Module\Dependency\Parser\Config\Xml'); + $this->parser = $objectManagerHelper->getObject(\Magento\Setup\Module\Dependency\Parser\Config\Xml::class); } /** diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Builder/AbstractBuilderTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Builder/AbstractBuilderTest.php index 9f9f620f479f274133e7d899855d952ed48b487d..b24ab45df69f9afd12c98da849df7c45651eb2e9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Builder/AbstractBuilderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Builder/AbstractBuilderTest.php @@ -24,11 +24,11 @@ class AbstractBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dependenciesParserMock = $this->getMock('Magento\Setup\Module\Dependency\ParserInterface'); - $this->reportWriterMock = $this->getMock('Magento\Setup\Module\Dependency\Report\WriterInterface'); + $this->dependenciesParserMock = $this->getMock(\Magento\Setup\Module\Dependency\ParserInterface::class); + $this->reportWriterMock = $this->getMock(\Magento\Setup\Module\Dependency\Report\WriterInterface::class); $this->builder = $this->getMockForAbstractClass( - 'Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder', + \Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder::class, ['dependenciesParser' => $this->dependenciesParserMock, 'reportWriter' => $this->reportWriterMock] ); } @@ -79,7 +79,7 @@ class AbstractBuilderTest extends \PHPUnit_Framework_TestCase ]; $parseResult = ['foo', 'bar', 'baz']; - $configMock = $this->getMock('\Magento\Setup\Module\Dependency\Report\Data\ConfigInterface'); + $configMock = $this->getMock(\Magento\Setup\Module\Dependency\Report\Data\ConfigInterface::class); $this->dependenciesParserMock->expects( $this->once() diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ChainTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ChainTest.php index 73e397a4a95af7081faac813e3213cb5e86219c8..0bb3795b8ad9140211af94eb1bb9367e1f572799 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ChainTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ChainTest.php @@ -16,7 +16,7 @@ class ChainTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new ObjectManager($this); /** @var \Magento\Setup\Module\Dependency\Report\Circular\Data\Chain $chain */ $chain = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Circular\Data\Chain', + \Magento\Setup\Module\Dependency\Report\Circular\Data\Chain::class, ['modules' => $modules] ); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ConfigTest.php index 450f98add160d24d7f368bed3dc91721046e72a2..c87f10af7eb596d2e2ab3067a2f35a3de1c8c9ac 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ConfigTest.php @@ -27,14 +27,14 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->moduleFirst = $this->getMock( - 'Magento\Setup\Module\Dependency\Report\Circular\Data\Module', + \Magento\Setup\Module\Dependency\Report\Circular\Data\Module::class, [], [], '', false ); $this->moduleSecond = $this->getMock( - 'Magento\Setup\Module\Dependency\Report\Circular\Data\Module', + \Magento\Setup\Module\Dependency\Report\Circular\Data\Module::class, [], [], '', @@ -43,7 +43,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new ObjectManager($this); $this->config = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Circular\Data\Config', + \Magento\Setup\Module\Dependency\Report\Circular\Data\Config::class, ['modules' => [$this->moduleFirst, $this->moduleSecond]] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ModuleTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ModuleTest.php index 88d72673b22703e9868f6452a23f8ed04882b68a..ec0e3abed1e240d95406c8b5694d035df99894e2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ModuleTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ModuleTest.php @@ -18,7 +18,7 @@ class ModuleTest extends \PHPUnit_Framework_TestCase { $objectManagerHelper = new ObjectManager($this); return $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Circular\Data\Module', + \Magento\Setup\Module\Dependency\Report\Circular\Data\Module::class, ['name' => $name, 'chains' => $chains] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Data/Config/AbstractConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Data/Config/AbstractConfigTest.php index e28eb3e0f56a8a6f23d6cde787a7ea564efd8281..7a1f419a0fb1df8f043f73dab6d8ff1fc02a5c02 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Data/Config/AbstractConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Data/Config/AbstractConfigTest.php @@ -13,7 +13,7 @@ class AbstractConfigTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig $config */ $config = $this->getMockForAbstractClass( - 'Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig', + \Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig::class, ['modules' => $modules] ); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ConfigTest.php index 7b1dc8ff231cc9bf0313c0097ffa6cc56b78d94b..f785861a29fd5e9e1c3496b9259e9aee21bc4502 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ConfigTest.php @@ -27,14 +27,14 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->moduleFirst = $this->getMock( - 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Module', + \Magento\Setup\Module\Dependency\Report\Dependency\Data\Module::class, [], [], '', false ); $this->moduleSecond = $this->getMock( - 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Module', + \Magento\Setup\Module\Dependency\Report\Dependency\Data\Module::class, [], [], '', @@ -43,7 +43,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new ObjectManager($this); $this->config = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Config', + \Magento\Setup\Module\Dependency\Report\Dependency\Data\Config::class, ['modules' => [$this->moduleFirst, $this->moduleSecond]] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/DependencyTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/DependencyTest.php index ff1d8b733dcfbc02a98c41a1f8ca3243b09fd5c9..293872644b38c54d99a367b29a38d0cf4bf22ace 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/DependencyTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/DependencyTest.php @@ -20,7 +20,7 @@ class DependencyTest extends \PHPUnit_Framework_TestCase { $objectManagerHelper = new ObjectManager($this); return $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency', + \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency::class, ['module' => $module, 'type' => $type] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ModuleTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ModuleTest.php index 642f0b812c08f06435ccb299b2b394830beeffc2..e79e6df92ebdd8eaa11e59fc8e0f22cb79a37b61 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ModuleTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ModuleTest.php @@ -27,14 +27,14 @@ class ModuleTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->dependencyFirst = $this->getMock( - 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency', + \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency::class, [], [], '', false ); $this->dependencySecond = $this->getMock( - 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency', + \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency::class, [], [], '', @@ -43,7 +43,7 @@ class ModuleTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new ObjectManager($this); $this->module = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Module', + \Magento\Setup\Module\Dependency\Report\Dependency\Data\Module::class, ['name' => 'name', 'dependencies' => [$this->dependencyFirst, $this->dependencySecond]] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/BuilderTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/BuilderTest.php index 5b2dff5a4ab9121a792c0ccbd5ee5e6a22f1ab63..db1d0a0d4f481bee868320326c76743a155b5bc3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/BuilderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/BuilderTest.php @@ -17,7 +17,9 @@ class BuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->builder = $objectManagerHelper->getObject('Magento\Setup\Module\Dependency\Report\Framework\Builder'); + $this->builder = $objectManagerHelper->getObject( + \Magento\Setup\Module\Dependency\Report\Framework\Builder::class + ); } /** diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ConfigTest.php index 2c2adf143d22fdcce8c869e64273de0b40472eb4..8d97ea4cdf0f5b55b414da0d1ac99d2069ff758b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ConfigTest.php @@ -27,14 +27,14 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->moduleFirst = $this->getMock( - 'Magento\Setup\Module\Dependency\Report\Framework\Data\Module', + \Magento\Setup\Module\Dependency\Report\Framework\Data\Module::class, [], [], '', false ); $this->moduleSecond = $this->getMock( - 'Magento\Setup\Module\Dependency\Report\Framework\Data\Module', + \Magento\Setup\Module\Dependency\Report\Framework\Data\Module::class, [], [], '', @@ -43,7 +43,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new ObjectManager($this); $this->config = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Framework\Data\Config', + \Magento\Setup\Module\Dependency\Report\Framework\Data\Config::class, ['modules' => [$this->moduleFirst, $this->moduleSecond]] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/DependencyTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/DependencyTest.php index 10832714c567dfb766c440eebd9df684487feba2..0e525c9370dc97eccaad476bc5f42138231716f3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/DependencyTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/DependencyTest.php @@ -18,7 +18,7 @@ class DependencyTest extends \PHPUnit_Framework_TestCase { $objectManagerHelper = new ObjectManager($this); return $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Framework\Data\Dependency', + \Magento\Setup\Module\Dependency\Report\Framework\Data\Dependency::class, ['lib' => $lib, 'count' => $count] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ModuleTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ModuleTest.php index 3d9714dfdb678234874cd5f8365798031aab4725..a25911a1e6c1f22bdf0b9b677a0da5cf46a6da0f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ModuleTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ModuleTest.php @@ -18,7 +18,7 @@ class ModuleTest extends \PHPUnit_Framework_TestCase { $objectManagerHelper = new ObjectManager($this); return $objectManagerHelper->getObject( - 'Magento\Setup\Module\Dependency\Report\Framework\Data\Module', + \Magento\Setup\Module\Dependency\Report\Framework\Data\Module::class, ['name' => $name, 'dependencies' => $dependencies] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Writer/Csv/AbstractWriterTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Writer/Csv/AbstractWriterTest.php index 27c75a95970aed02d27f0af27514a4834781fdc9..46eb07d7d91f13bb7fda2397bd522a21e0e375a9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Writer/Csv/AbstractWriterTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Writer/Csv/AbstractWriterTest.php @@ -19,10 +19,10 @@ class AbstractWriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->csvMock = $this->getMock('Magento\Framework\File\Csv', [], [], '', false); + $this->csvMock = $this->getMock(\Magento\Framework\File\Csv::class, [], [], '', false); $this->writer = $this->getMockForAbstractClass( - 'Magento\Setup\Module\Dependency\Report\Writer\Csv\AbstractWriter', + \Magento\Setup\Module\Dependency\Report\Writer\Csv\AbstractWriter::class, ['writer' => $this->csvMock] ); } @@ -30,7 +30,7 @@ class AbstractWriterTest extends \PHPUnit_Framework_TestCase public function testWrite() { $options = ['report_filename' => 'some_filename']; - $configMock = $this->getMock('Magento\Setup\Module\Dependency\Report\Data\ConfigInterface'); + $configMock = $this->getMock(\Magento\Setup\Module\Dependency\Report\Data\ConfigInterface::class); $preparedData = ['foo', 'baz', 'bar']; $this->writer->expects( @@ -55,7 +55,7 @@ class AbstractWriterTest extends \PHPUnit_Framework_TestCase */ public function testWriteWithWrongOptionReportFilename($options) { - $configMock = $this->getMock('Magento\Setup\Module\Dependency\Report\Data\ConfigInterface'); + $configMock = $this->getMock(\Magento\Setup\Module\Dependency\Report\Data\ConfigInterface::class); $this->writer->write($options, $configMock); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ApplicationCodeGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ApplicationCodeGeneratorTest.php index 37235614c075bc7760a77f5dbc9b62c88c12913b..442efad67e344028bcc630b08c1af80e2ad53154 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ApplicationCodeGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ApplicationCodeGeneratorTest.php @@ -29,13 +29,14 @@ class ApplicationCodeGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->directoryScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner') - ->disableOriginalConstructor() + $this->directoryScannerMock = $this->getMockBuilder( + \Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner::class + )->disableOriginalConstructor() ->getMock(); - $this->phpScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\PhpScanner') + $this->phpScannerMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Scanner\PhpScanner::class) ->disableOriginalConstructor() ->getMock(); - $this->classesScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Reader\ClassesScanner') + $this->classesScannerMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Reader\ClassesScanner::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/AreaTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/AreaTest.php index 72b1974dab23a286fd6b15c4377aaa5ad56b3fe9..3f95082473208ff29e663bcb0f793b3e1d7affe9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/AreaTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/AreaTest.php @@ -38,19 +38,20 @@ class AreaTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->areaListMock = $this->getMockBuilder('Magento\Framework\App\AreaList') + $this->areaListMock = $this->getMockBuilder(\Magento\Framework\App\AreaList::class) ->disableOriginalConstructor() ->getMock(); - $this->areaInstancesNamesList = $this->getMockBuilder('\Magento\Setup\Module\Di\Code\Reader\Decorator\Area') + $this->areaInstancesNamesList = + $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Reader\Decorator\Area::class) ->disableOriginalConstructor() ->getMock(); - $this->configReaderMock = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\Reader') + $this->configReaderMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Compiler\Config\Reader::class) ->disableOriginalConstructor() ->getMock(); - $this->configWriterMock = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\WriterInterface') + $this->configWriterMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Compiler\Config\WriterInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->configChain = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\ModificationChain') + $this->configChain = $this->getMockBuilder(\Magento\Setup\Module\Di\Compiler\Config\ModificationChain::class) ->disableOriginalConstructor() ->getMock(); } @@ -97,7 +98,7 @@ class AreaTest extends \PHPUnit_Framework_TestCase $this->configReaderMock->expects($this->once()) ->method('generateCachePerScope') ->with( - $this->isInstanceOf('Magento\Setup\Module\Di\Definition\Collection'), + $this->isInstanceOf(\Magento\Setup\Module\Di\Definition\Collection::class), App\Area::AREA_GLOBAL ) ->willReturn($generatedConfig); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/InterceptionCacheTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/InterceptionCacheTest.php index 1bdcb5f8e904bf8a199bc9f19217fbec9832d8eb..d283d2ff1a3f02ae2ee5dac3d180d96fd48e3c4a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/InterceptionCacheTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/InterceptionCacheTest.php @@ -21,12 +21,12 @@ class InterceptionCacheTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->configMock = $this->getMockBuilder('Magento\Framework\Interception\Config\Config') + $this->configMock = $this->getMockBuilder(\Magento\Framework\Interception\Config\Config::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); $this->interceptionsListMock = $this->getMockBuilder( - 'Magento\Setup\Module\Di\Code\Reader\Decorator\Interceptions' + \Magento\Setup\Module\Di\Code\Reader\Decorator\Interceptions::class ) ->setMethods([]) ->disableOriginalConstructor() diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/OperationFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/OperationFactoryTest.php index 90c066d3c9261a18751a69bf0d9e55135fea32a2..cf00a7314ef59cfc0dbec8bb5c57f078ea39715b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/OperationFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/OperationFactoryTest.php @@ -25,10 +25,10 @@ class OperationFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->setMethods([]) ->getMock(); - $objectManagerProviderMock = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $objectManagerProviderMock = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProviderMock->expects($this->once())->method('get')->willReturn($this->objectManagerMock); $this->factory = new OperationFactory( $objectManagerProviderMock @@ -42,7 +42,7 @@ class OperationFactoryTest extends \PHPUnit_Framework_TestCase */ public function testCreateSuccess($alias, $arguments, $instanceName) { - $operationInstance = $this->getMockBuilder('Magento\Setup\Module\Di\App\Task\OperationInterface') + $operationInstance = $this->getMockBuilder(\Magento\Setup\Module\Di\App\Task\OperationInterface::class) ->getMock(); $this->objectManagerMock->expects($this->once()) @@ -57,7 +57,7 @@ class OperationFactoryTest extends \PHPUnit_Framework_TestCase { $notRegisteredOperation = 'coffee'; $this->setExpectedException( - 'Magento\Setup\Module\Di\App\Task\OperationException', + \Magento\Setup\Module\Di\App\Task\OperationException::class, sprintf('Unrecognized operation "%s"', $notRegisteredOperation), OperationException::UNAVAILABLE_OPERATION ); @@ -70,9 +70,9 @@ class OperationFactoryTest extends \PHPUnit_Framework_TestCase public function aliasesDataProvider() { return [ - [OperationFactory::AREA_CONFIG_GENERATOR, [], 'Magento\Setup\Module\Di\App\Task\Operation\Area'], - [OperationFactory::INTERCEPTION, null, 'Magento\Setup\Module\Di\App\Task\Operation\Interception'], - [OperationFactory::INTERCEPTION_CACHE, 1, 'Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache'], + [OperationFactory::AREA_CONFIG_GENERATOR, [], \Magento\Setup\Module\Di\App\Task\Operation\Area::class], + [OperationFactory::INTERCEPTION, null, \Magento\Setup\Module\Di\App\Task\Operation\Interception::class], + [OperationFactory::INTERCEPTION_CACHE, 1, \Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache::class], ]; } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php index e97a238106d18aecfe67ef5c60ef13179d7ca51c..bd19c2e0552139ecdb005d4f5c97f0a86dadbacf 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php @@ -29,18 +29,18 @@ class ProxyGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->proxyScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\XmlScanner') + $this->proxyScannerMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Scanner\XmlScanner::class) ->disableOriginalConstructor() ->getMock(); $this->configurationScannerMock = $this->getMockBuilder( - 'Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner' + \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner::class )->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Di\App\Task\Operation\ProxyGenerator', + \Magento\Setup\Module\Di\App\Task\Operation\ProxyGenerator::class, [ 'proxyScanner' => $this->proxyScannerMock, 'configurationScanner' => $this->configurationScannerMock, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php index 9c43f5f270887282bcd31a6b225550b2589fb88c..b23f8844fea510b5e35b7d034a0b711471422b08 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php @@ -22,7 +22,6 @@ class RepositoryGeneratorTest extends \PHPUnit_Framework_TestCase */ private $classesScannerMock; - /** * @var \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner | \PHPUnit_Framework_MockObject_MockObject */ @@ -35,19 +34,20 @@ class RepositoryGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->repositoryScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\RepositoryScanner') + $this->repositoryScannerMock = + $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Scanner\RepositoryScanner::class) ->disableOriginalConstructor() ->getMock(); - $this->classesScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Reader\ClassesScanner') + $this->classesScannerMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Reader\ClassesScanner::class) ->disableOriginalConstructor() ->getMock(); $this->configurationScannerMock = $this->getMockBuilder( - 'Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner' + \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner::class )->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator', + \Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator::class, [ 'repositoryScanner' => $this->repositoryScannerMock, 'classesScanner' => $this->classesScannerMock, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php index a53a6e5621cea3e54ca81f3f526557935e11c533..2c35efa1f2458e2f1a4903df4aafa2e4db6971e0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php @@ -31,16 +31,16 @@ class ServiceDataAttributesGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configurationScannerMock = $this->getMockBuilder( - 'Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner' + \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner::class )->disableOriginalConstructor() ->getMock(); $this->serviceDataAttributesScannerMock = $this->getMockBuilder( - 'Magento\Setup\Module\Di\Code\Scanner\ServiceDataAttributesScanner' + \Magento\Setup\Module\Di\Code\Scanner\ServiceDataAttributesScanner::class )->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Di\App\Task\Operation\ServiceDataAttributesGenerator', + \Magento\Setup\Module\Di\App\Task\Operation\ServiceDataAttributesGenerator::class, [ 'serviceDataAttributesScanner' => $this->serviceDataAttributesScannerMock, 'configurationScanner' => $this->configurationScannerMock, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Generator/InterceptionConfigurationBuilderTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Generator/InterceptionConfigurationBuilderTest.php index 00ba3b25ec24e9bfd3f2dd1692a0dbfa7ea726c5..deae552a514e8ba379086dc23f01e89e8c593da6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Generator/InterceptionConfigurationBuilderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Generator/InterceptionConfigurationBuilderTest.php @@ -13,6 +13,7 @@ class InterceptionConfigurationBuilderTest extends \PHPUnit_Framework_TestCase * @var \Magento\Setup\Module\Di\Code\Generator\InterceptionConfigurationBuilder */ protected $model; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -41,35 +42,41 @@ class InterceptionConfigurationBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->interceptionConfig = $this->getMock( - 'Magento\Framework\Interception\Config\Config', + \Magento\Framework\Interception\Config\Config::class, ['hasPlugins'], [], '', false ); $this->pluginList = $this->getMock( - 'Magento\Setup\Module\Di\Code\Generator\PluginList', + \Magento\Setup\Module\Di\Code\Generator\PluginList::class, ['setInterceptedClasses', 'setScopePriorityScheme', 'getPluginsConfig'], [], '', false ); $this->cacheManager = $this->getMock( - 'Magento\Framework\App\Cache\Manager', + \Magento\Framework\App\Cache\Manager::class, [], [], '', false ); $this->interceptableValidator = $this->getMock( - 'Magento\Framework\ObjectManager\InterceptableValidator', + \Magento\Framework\ObjectManager\InterceptableValidator::class, [], [], '', false ); - $this->typeReader = $this->getMock('Magento\Setup\Module\Di\Code\Reader\Type', ['isConcrete'], [], '', false); + $this->typeReader = $this->getMock( + \Magento\Setup\Module\Di\Code\Reader\Type::class, + ['isConcrete'], + [], + '', + false + ); $this->model = new \Magento\Setup\Module\Di\Code\Generator\InterceptionConfigurationBuilder( $this->interceptionConfig, $this->pluginList, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/ClassReaderDecoratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/ClassReaderDecoratorTest.php index 406fa090d902cc19a6bbf41fbd6d13e5a753ec1a..5dcdc875a0d5e66615800e7a68e0f5d7ffe84a71 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/ClassReaderDecoratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/ClassReaderDecoratorTest.php @@ -21,7 +21,7 @@ class ClassReaderDecoratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->classReaderMock = $this->getMockBuilder('\Magento\Framework\Code\Reader\ClassReader') + $this->classReaderMock = $this->getMockBuilder(\Magento\Framework\Code\Reader\ClassReader::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/AreaTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/AreaTest.php index d3bc6dc5dfb3efc8dc9d284d1f34fab6f98eff09..234c647ca12d01a62e6b8e0f5d523c463aa3c4d2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/AreaTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/AreaTest.php @@ -31,13 +31,13 @@ class AreaTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->classesScannerMock = $this->getMockBuilder('\Magento\Setup\Module\Di\Code\Reader\ClassesScanner') + $this->classesScannerMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Reader\ClassesScanner::class) ->disableOriginalConstructor() ->setMethods(['getList']) ->getMock(); $this->classReaderDecoratorMock = $this->getMockBuilder( - '\Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator' + \Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator::class ) ->disableOriginalConstructor() ->setMethods(['getConstructor']) diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/DirectoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/DirectoryTest.php index 78ff6a6966dac7e822fedab39bd1bc87378ebd65..7e6c2f1ff1b03baf423c5b6663c45b044e0aa42c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/DirectoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/DirectoryTest.php @@ -41,22 +41,22 @@ class DirectoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->logMock = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Log\Log') + $this->logMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Compiler\Log\Log::class) ->disableOriginalConstructor() ->setMethods(['add']) ->getMock(); - $this->classesScanner = $this->getMockBuilder('\Magento\Setup\Module\Di\Code\Reader\ClassesScanner') + $this->classesScanner = $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Reader\ClassesScanner::class) ->disableOriginalConstructor() ->setMethods(['getList']) ->getMock(); - $this->classReaderMock = $this->getMockBuilder('\Magento\Framework\Code\Reader\ClassReader') + $this->classReaderMock = $this->getMockBuilder(\Magento\Framework\Code\Reader\ClassReader::class) ->disableOriginalConstructor() ->setMethods(['getParents']) ->getMock(); - $this->validatorMock = $this->getMockBuilder('\Magento\Framework\Code\Validator') + $this->validatorMock = $this->getMockBuilder(\Magento\Framework\Code\Validator::class) ->disableOriginalConstructor() ->setMethods(['validate']) ->getMock(); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/InterceptionsTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/InterceptionsTest.php index 7c120f799bd8558d323022d141ff8c6a1490dd2c..212575e644d7ca377f14c16a9531dd1b587129c2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/InterceptionsTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/InterceptionsTest.php @@ -41,22 +41,22 @@ class InterceptionsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->logMock = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Log\Log') + $this->logMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Compiler\Log\Log::class) ->disableOriginalConstructor() ->setMethods(['add', 'report']) ->getMock(); - $this->classesScanner = $this->getMockBuilder('\Magento\Setup\Module\Di\Code\Reader\ClassesScanner') + $this->classesScanner = $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Reader\ClassesScanner::class) ->disableOriginalConstructor() ->setMethods(['getList']) ->getMock(); - $this->classReaderMock = $this->getMockBuilder('\Magento\Framework\Code\Reader\ClassReader') + $this->classReaderMock = $this->getMockBuilder(\Magento\Framework\Code\Reader\ClassReader::class) ->disableOriginalConstructor() ->setMethods(['getParents']) ->getMock(); - $this->validatorMock = $this->getMockBuilder('\Magento\Framework\Code\Validator') + $this->validatorMock = $this->getMockBuilder(\Magento\Framework\Code\Validator::class) ->disableOriginalConstructor() ->setMethods(['validate', 'add']) ->getMock(); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/CompositeScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/CompositeScannerTest.php index 5b6759b6e37397c422dc138addef7e68a09a11f0..073bb18b379deb1dadd8bcbafe9396b99451c2e9 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/CompositeScannerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/CompositeScannerTest.php @@ -23,8 +23,8 @@ class CompositeScannerTest extends \PHPUnit_Framework_TestCase $configFiles = ['one/file/config', 'two/file/config']; $files = ['php' => $phpFiles, 'config' => $configFiles]; - $scannerPhp = $this->getMock('Magento\Setup\Module\Di\Code\Scanner\ScannerInterface'); - $scannerXml = $this->getMock('Magento\Setup\Module\Di\Code\Scanner\ScannerInterface'); + $scannerPhp = $this->getMock(\Magento\Setup\Module\Di\Code\Scanner\ScannerInterface::class); + $scannerXml = $this->getMock(\Magento\Setup\Module\Di\Code\Scanner\ScannerInterface::class); $scannerPhpExpected = ['Model_OneProxy', 'Model_TwoFactory']; $scannerXmlExpected = ['Model_OneProxy', 'Model_ThreeFactory']; diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ConfigurationScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ConfigurationScannerTest.php index f36a120d819d133f278a6743dec72876926f5517..53e48abfdb2ca7f7081477ad85d5792c81e62235 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ConfigurationScannerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ConfigurationScannerTest.php @@ -24,17 +24,17 @@ class ConfigurationScannerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->fileResolverMock = $this->getMockBuilder('Magento\Framework\App\Config\FileResolver') + $this->fileResolverMock = $this->getMockBuilder(\Magento\Framework\App\Config\FileResolver::class) ->disableOriginalConstructor() ->getMock(); - $this->areaListMock = $this->getMockBuilder('Magento\Framework\App\AreaList') + $this->areaListMock = $this->getMockBuilder(\Magento\Framework\App\AreaList::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManagerHelper->getObject( - 'Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner', + \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner::class, [ 'fileResolver' => $this->fileResolverMock, 'areaList' => $this->areaListMock, @@ -45,7 +45,7 @@ class ConfigurationScannerTest extends \PHPUnit_Framework_TestCase public function testScan() { $codes = ['code1', 'code2']; - $iteratorMock = $this->getMockBuilder('Magento\Framework\Config\FileIterator') + $iteratorMock = $this->getMockBuilder(\Magento\Framework\Config\FileIterator::class) ->disableOriginalConstructor() ->getMock(); $this->areaListMock->expects($this->once()) diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php index e0a85322e6720960a3081607ea38119e36b73e50..4534c532792fc741ccd6ced6dfbfdc2aaaadfcc6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php @@ -34,7 +34,7 @@ class PhpScannerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = new \Magento\Setup\Module\Di\Code\Scanner\PhpScanner( - $this->_logMock = $this->getMock('\Magento\Setup\Module\Di\Compiler\Log\Log', [], [], '', false) + $this->_logMock = $this->getMock(\Magento\Setup\Module\Di\Compiler\Log\Log::class, [], [], '', false) ); $this->_testDir = str_replace('\\', '/', realpath(__DIR__ . '/../../') . '/_files'); $this->_testFiles = [ diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PluginScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PluginScannerTest.php index 844959dd501e9ebf106e3c240dae834ee99c7375..e77e98dff1c8fe491f9427955bb6d032483f98a0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PluginScannerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PluginScannerTest.php @@ -28,7 +28,7 @@ class PluginScannerTest extends \PHPUnit_Framework_TestCase public function testCollectEntities() { $actual = $this->_model->collectEntities($this->_testFiles); - $expected = ['Magento\Framework\App\Cache\TagPlugin', 'Magento\Store\Model\Action\Plugin']; + $expected = [\Magento\Framework\App\Cache\TagPlugin::class, \Magento\Store\Model\Action\Plugin::class]; $this->assertEquals($expected, $actual); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ServiceDataAttributesScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ServiceDataAttributesScannerTest.php index 3409f073f3156047416e932d153327aa7bae2859..1023f6b41b0778dbc114dc3ecb9bfafecc169d59 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ServiceDataAttributesScannerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ServiceDataAttributesScannerTest.php @@ -30,10 +30,10 @@ class ServiceDataAttributesScannerTest extends \PHPUnit_Framework_TestCase { $files = [$this->testFile]; $expectedResult = [ - 'Magento\Sales\Api\Data\OrderExtensionInterface', - 'Magento\Sales\Api\Data\OrderExtension', - 'Magento\Sales\Api\Data\OrderItemExtensionInterface', - 'Magento\Sales\Api\Data\OrderItemExtension', + \Magento\Sales\Api\Data\OrderExtensionInterface::class, + \Magento\Sales\Api\Data\OrderExtension::class, + \Magento\Sales\Api\Data\OrderItemExtensionInterface::class, + \Magento\Sales\Api\Data\OrderItemExtension::class, ]; $this->assertSame($expectedResult, $this->model->collectEntities($files)); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlInterceptorScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlInterceptorScannerTest.php index 0e58ef50f698c2bd718f7160684753de5beb187e..fa8cf85a20867538e21b2d684bb69943e9689064 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlInterceptorScannerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlInterceptorScannerTest.php @@ -36,8 +36,8 @@ class XmlInterceptorScannerTest extends \PHPUnit_Framework_TestCase { $actual = $this->_model->collectEntities($this->_testFiles); $expected = [ - 'Magento\Framework\App\Cache\Interceptor', - 'Magento\Framework\App\Action\Context\Interceptor', + \Magento\Framework\App\Cache\Interceptor::class, + \Magento\Framework\App\Action\Context\Interceptor::class, ]; $this->assertEquals($expected, $actual); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlScannerTest.php index 61c9cb7c9ccbe2dcef74f1fe55bf22b854f17e21..02e603e4a2632a8c5dece9b331acfbf4e35f303b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlScannerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlScannerTest.php @@ -28,7 +28,7 @@ class XmlScannerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = new \Magento\Setup\Module\Di\Code\Scanner\XmlScanner( - $this->_logMock = $this->getMock('\Magento\Setup\Module\Di\Compiler\Log\Log', [], [], '', false) + $this->_logMock = $this->getMock(\Magento\Setup\Module\Di\Compiler\Log\Log::class, [], [], '', false) ); $testDir = __DIR__ . '/../../' . '/_files'; $this->_testFiles = [ diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/ArgumentsResolverTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/ArgumentsResolverTest.php index 8ba9e8120c876db109f3fb611d1b5036785b9419..34bbcf118b19aa1106a5b5558f42dbcb30cd3df3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/ArgumentsResolverTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/ArgumentsResolverTest.php @@ -23,7 +23,7 @@ class ArgumentsResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->diContainerConfig = $this->getMock( - 'Magento\Framework\ObjectManager\ConfigInterface', + \Magento\Framework\ObjectManager\ConfigInterface::class, [], [], '', @@ -78,8 +78,6 @@ class ArgumentsResolverTest extends \PHPUnit_Framework_TestCase new ConstructorArgument(['value_null', null, false, null]), ]; - - $this->diContainerConfig->expects($this->any()) ->method('isShared') ->willReturnMap( diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ModificationChainTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ModificationChainTest.php index 7f2ffcb032ef1eef992b82957cee59f4f355c5af..5fb8f164cee898e52c25de576e28c888af3e96b0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ModificationChainTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ModificationChainTest.php @@ -13,10 +13,12 @@ class ModificationChainTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $modificationsList = []; - $modificationsList[] = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\ModificationInterface') - ->getMock(); - $modificationsList[] = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\ModificationInterface') - ->getMock(); + $modificationsList[] = $this->getMockBuilder( + \Magento\Setup\Module\Di\Compiler\Config\ModificationInterface::class + )->getMock(); + $modificationsList[] = $this->getMockBuilder( + \Magento\Setup\Module\Di\Compiler\Config\ModificationInterface::class + )->getMock(); new ModificationChain($modificationsList); } @@ -25,10 +27,12 @@ class ModificationChainTest extends \PHPUnit_Framework_TestCase { $this->setExpectedException('InvalidArgumentException', 'Wrong modifier provided'); $modificationsList = []; - $modificationsList[] = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\ModificationInterface') - ->getMock(); - $modificationsList[] = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\ModificationInterface') - ->getMock(); + $modificationsList[] = $this->getMockBuilder( + \Magento\Setup\Module\Di\Compiler\Config\ModificationInterface::class + )->getMock(); + $modificationsList[] = $this->getMockBuilder( + \Magento\Setup\Module\Di\Compiler\Config\ModificationInterface::class + )->getMock(); $modificationsList[] = 'banana'; new ModificationChain($modificationsList); @@ -48,9 +52,9 @@ class ModificationChainTest extends \PHPUnit_Framework_TestCase 'data' => [1, 2, 3, 1, 1] ]; - $modifier1 = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\ModificationInterface') + $modifier1 = $this->getMockBuilder(\Magento\Setup\Module\Di\Compiler\Config\ModificationInterface::class) ->getMock(); - $modifier2 = $this->getMockBuilder('Magento\Setup\Module\Di\Compiler\Config\ModificationInterface') + $modifier2 = $this->getMockBuilder(\Magento\Setup\Module\Di\Compiler\Config\ModificationInterface::class) ->getMock(); $modificationsList = [$modifier1, $modifier2]; diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php index 4fb827bc67012da6b57aeb2471c956867a519248..929f3100efde5032cd3ad2eca957efc9bf33c48a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php @@ -47,17 +47,20 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->diContainerConfig = $this->getMock('Magento\Framework\ObjectManager\ConfigInterface', [], [], '', false); - $this->configLoader = $this->getMock('Magento\Framework\App\ObjectManager\ConfigLoader', [], [], '', false); + $this->diContainerConfig = + $this->getMock(\Magento\Framework\ObjectManager\ConfigInterface::class, [], [], '', false); + $this->configLoader = + $this->getMock(\Magento\Framework\App\ObjectManager\ConfigLoader::class, [], [], '', false); + $this->argumentsResolverFactory = $this->getMock( - 'Magento\Setup\Module\Di\Compiler\ArgumentsResolverFactory', + \Magento\Setup\Module\Di\Compiler\ArgumentsResolverFactory::class, [], [], '', false ); $this->argumentsResolver = $this->getMock( - 'Magento\Setup\Module\Di\Compiler\ArgumentsResolver', + \Magento\Setup\Module\Di\Compiler\ArgumentsResolver::class, [], [], '', @@ -67,13 +70,13 @@ class ReaderTest extends \PHPUnit_Framework_TestCase ->method('create') ->willReturn($this->argumentsResolver); $this->classReaderDecorator = $this->getMock( - 'Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator', + \Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator::class, [], [], '', false ); - $this->typeReader = $this->getMock('Magento\Setup\Module\Di\Code\Reader\Type', [], [], '', false); + $this->typeReader = $this->getMock(\Magento\Setup\Module\Di\Code\Reader\Type::class, [], [], '', false); $this->model = new \Magento\Setup\Module\Di\Compiler\Config\Reader( $this->diContainerConfig, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Definition/CollectionTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Definition/CollectionTest.php index 2d1c9ac0a9b6e112521c8986fb3fff9aa9f18b30..578f3a82dbca352093d58a1244874baeee649274 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Definition/CollectionTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Definition/CollectionTest.php @@ -56,7 +56,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->collectionMock = $this->getMockBuilder('\Magento\Setup\Module\Di\Definition\Collection') + $this->collectionMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Definition\Collection::class) ->setMethods([])->getMock(); $this->model = new \Magento\Setup\Module\Di\Definition\Collection(); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/bootstrap.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/bootstrap.php index 1eed8db71cb095f2551012e5a0d70a205f839fb9..654c282d88c07829574bf0609caaaffa3c7beaf0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/bootstrap.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/bootstrap.php @@ -5,4 +5,4 @@ */ $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); -$bootstrapFactory = $objectManager->getObject('Magento\Bootstrap\ModelFactory'); +$bootstrapFactory = $objectManager->getObject(\Magento\Bootstrap\ModelFactory::class); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php index 619819e48b36099ddf9d3bcc8d49c3fd03e72651..7631f8a6bfb506627723ab1ccdfc8605e362dae0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php @@ -41,6 +41,6 @@ class Test */ public function testHelper(\Magento\SomeModule\ElementFactory $factory, array $data = []) { - $factory->create('Magento\SomeModule\ElementFactory', ['data' => $data]); + $factory->create(\Magento\SomeModule\ElementFactory::class, ['data' => $data]); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/Test.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/Test.php index e20df8dcb21b1e0d5d6b431624fd39df512ab5ac..df87a2b270c48e6b60fea2acf57c9fdc5ffb792b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/Test.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/Test.php @@ -21,6 +21,6 @@ class Test */ public function testModel(\Magento\SomeModule\ModelFactory $factory, array $data = []) { - $factory->create('Magento\SomeModule\Model\BlockFactory', ['data' => $data]); + $factory->create(\Magento\SomeModule\Model\BlockFactory::class, ['data' => $data]); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/ContextTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/ContextTest.php index 42825a947fd4614f48d1fb99f26cf260379680a4..fa9f915de9e8cb70484d38d8c141c12e9431fe21 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/ContextTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/ContextTest.php @@ -22,7 +22,13 @@ class ContextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); + $this->componentRegistrar = $this->getMock( + \Magento\Framework\Component\ComponentRegistrar::class, + [], + [], + '', + false + ); } /** diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/GeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/GeneratorTest.php index 37fabc7d2b8d6434bcc11ec42327bc6a997e30a9..9c182d31f7baeee5e735d1ddb25e9c6856443de2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/GeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/GeneratorTest.php @@ -42,22 +42,22 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->parserMock = $this->getMock('Magento\Setup\Module\I18n\Parser\Parser', [], [], '', false); + $this->parserMock = $this->getMock(\Magento\Setup\Module\I18n\Parser\Parser::class, [], [], '', false); $this->contextualParserMock = $this->getMock( - 'Magento\Setup\Module\I18n\Parser\Contextual', + \Magento\Setup\Module\I18n\Parser\Contextual::class, [], [], '', false ); - $this->writerMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\WriterInterface'); - $this->factoryMock = $this->getMock('Magento\Setup\Module\I18n\Factory', [], [], '', false); + $this->writerMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\WriterInterface::class); + $this->factoryMock = $this->getMock(\Magento\Setup\Module\I18n\Factory::class, [], [], '', false); $this->factoryMock->expects($this->any()) ->method('createDictionaryWriter') ->will($this->returnValue($this->writerMock)); $this->optionsResolverFactory = $this->getMock( - 'Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory', + \Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory::class, [], [], '', @@ -66,7 +66,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->generator = $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Dictionary\Generator', + \Magento\Setup\Module\I18n\Dictionary\Generator::class, [ 'parser' => $this->parserMock, 'contextualParser' => $this->contextualParserMock, @@ -80,14 +80,20 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase { $outputFilename = 'test'; - $phrase = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phrase = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $this->factoryMock->expects($this->once()) ->method('createDictionaryWriter') ->with($outputFilename) ->will($this->returnSelf()); $this->parserMock->expects($this->any())->method('getPhrases')->will($this->returnValue([$phrase])); $options = []; - $optionResolver = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Options\Resolver', [], [], '', false); + $optionResolver = $this->getMock( + \Magento\Setup\Module\I18n\Dictionary\Options\Resolver::class, + [], + [], + '', + false + ); $optionResolver->expects($this->once()) ->method('getOptions') ->will($this->returnValue($options)); @@ -106,7 +112,8 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $baseDir = 'right_parser'; $outputFilename = 'file.csv'; $filesOptions = ['file1', 'file2']; - $optionResolver = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Options\Resolver', [], [], '', false); + $optionResolver = + $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Options\Resolver::class, [], [], '', false); $optionResolver->expects($this->once()) ->method('getOptions') ->will($this->returnValue($filesOptions)); @@ -121,7 +128,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo($baseDir), $this->equalTo(false)) ->will($this->returnValue($optionResolver)); $this->parserMock->expects($this->once())->method('parse')->with($filesOptions); - $phrase = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phrase = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $this->parserMock->expects($this->once())->method('getPhrases')->will($this->returnValue([$phrase])); $this->generator->generate($baseDir, $outputFilename); } @@ -131,7 +138,8 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $baseDir = 'right_parser2'; $outputFilename = 'file.csv'; $filesOptions = ['file1', 'file2']; - $optionResolver = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Options\Resolver', [], [], '', false); + $optionResolver = + $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Options\Resolver::class, [], [], '', false); $optionResolver->expects($this->once()) ->method('getOptions') ->will($this->returnValue($filesOptions)); @@ -141,7 +149,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($optionResolver)); $this->contextualParserMock->expects($this->once())->method('parse')->with($filesOptions); - $phrase = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phrase = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $this->contextualParserMock->expects($this->once())->method('getPhrases')->will($this->returnValue([$phrase])); $this->factoryMock->expects($this->once()) @@ -156,7 +164,8 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase { $baseDir = 'WritingPhrases'; $filesOptions = ['file1', 'file2']; - $optionResolver = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Options\Resolver', [], [], '', false); + $optionResolver = + $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Options\Resolver::class, [], [], '', false); $optionResolver->expects($this->once()) ->method('getOptions') ->will($this->returnValue($filesOptions)); @@ -166,8 +175,8 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($optionResolver)); $phrases = [ - $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false), - $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false), + $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false), + $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false), ]; $this->parserMock->expects($this->once())->method('getPhrases')->will($this->returnValue($phrases)); @@ -186,7 +195,8 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $baseDir = 'no_phrases'; $outputFilename = 'no_file.csv'; $filesOptions = ['file1', 'file2']; - $optionResolver = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Options\Resolver', [], [], '', false); + $optionResolver = + $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Options\Resolver::class, [], [], '', false); $optionResolver->expects($this->once()) ->method('getOptions') ->will($this->returnValue($filesOptions)); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Loader/File/AbstractFileTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Loader/File/AbstractFileTest.php index bcdabf456185b3f7b268040116b17d10db22ce9b..b0a04f6c6c813574a436348b6dd790d0ee0b6d03 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Loader/File/AbstractFileTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Loader/File/AbstractFileTest.php @@ -24,8 +24,8 @@ class AbstractFileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_dictionaryMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary', [], [], '', false); - $this->_factoryMock = $this->getMock('Magento\Setup\Module\I18n\Factory', [], [], '', false); + $this->_dictionaryMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary::class, [], [], '', false); + $this->_factoryMock = $this->getMock(\Magento\Setup\Module\I18n\Factory::class, [], [], '', false); } /** @@ -35,7 +35,7 @@ class AbstractFileTest extends \PHPUnit_Framework_TestCase public function testLoadWrongFile() { $abstractLoaderMock = $this->getMockForAbstractClass( - 'Magento\Setup\Module\I18n\Dictionary\Loader\File\AbstractFile', + \Magento\Setup\Module\I18n\Dictionary\Loader\File\AbstractFile::class, [], '', false @@ -48,7 +48,7 @@ class AbstractFileTest extends \PHPUnit_Framework_TestCase public function testLoad() { $abstractLoaderMock = $this->getMockForAbstractClass( - 'Magento\Setup\Module\I18n\Dictionary\Loader\File\AbstractFile', + \Magento\Setup\Module\I18n\Dictionary\Loader\File\AbstractFile::class, [$this->_factoryMock], '', true, @@ -71,8 +71,8 @@ class AbstractFileTest extends \PHPUnit_Framework_TestCase $this->returnValue(['phrase2', 'translation2', 'context_type2', 'context_value2']) ); - $phraseFirstMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseSecondMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phraseFirstMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseSecondMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $this->_factoryMock->expects( $this->once() @@ -119,7 +119,7 @@ class AbstractFileTest extends \PHPUnit_Framework_TestCase public function testErrorsInPhraseCreating() { $abstractLoaderMock = $this->getMockForAbstractClass( - 'Magento\Setup\Module\I18n\Dictionary\Loader\File\AbstractFile', + \Magento\Setup\Module\I18n\Dictionary\Loader\File\AbstractFile::class, [$this->_factoryMock], '', true, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverFactoryTest.php index e3ab85b7cf7ecbb404606ba77a7b2ad6b25c6bfe..e065a717697a6ae7b4a0554175d30e80c2691a83 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverFactoryTest.php @@ -15,7 +15,7 @@ class ResolverFactoryTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory $resolverFactory */ $resolverFactory = $objectManagerHelper - ->getObject('Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory'); + ->getObject(\Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory::class); $this->assertInstanceOf( \Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory::DEFAULT_RESOLVER, $resolverFactory->create('some_dir', true) @@ -31,7 +31,7 @@ class ResolverFactoryTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory $resolverFactory */ $resolverFactory = $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory', + \Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory::class, [ 'resolverClass' => 'stdClass' ] diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverTest.php index c5dc4f7c249be6354b180cfc88fe6a4641efc28d..c7731e3225db68ac6e989baa62615bd604fdb7e6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverTest.php @@ -21,7 +21,7 @@ class ResolverTest extends \PHPUnit_Framework_TestCase public function testGetOptions($directory, $withContext, $result) { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); + $componentRegistrar = $this->getMock(\Magento\Framework\Component\ComponentRegistrar::class, [], [], '', false); $root = __DIR__ . '/_files/source'; $componentRegistrar->expects($this->any()) ->method('getPaths') @@ -31,11 +31,11 @@ class ResolverTest extends \PHPUnit_Framework_TestCase [ComponentRegistrar::THEME, [$root . '/app/design']], ]) ); - $directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $directoryList = $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); $directoryList->expects($this->any())->method('getRoot')->willReturn('root'); /** @var \Magento\Setup\Module\I18n\Dictionary\Options\Resolver $resolver */ $resolver = $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Dictionary\Options\Resolver', + \Magento\Setup\Module\I18n\Dictionary\Options\Resolver::class, [ 'directory' => $directory, 'withContext' => $withContext, @@ -119,16 +119,16 @@ class ResolverTest extends \PHPUnit_Framework_TestCase */ public function testGetOptionsWrongDir($directory, $withContext, $message) { - $componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); + $componentRegistrar = $this->getMock(\Magento\Framework\Component\ComponentRegistrar::class, [], [], '', false); $root = __DIR__ . '/_files/source'; $componentRegistrar->expects($this->any()) ->method('getPaths') ->willReturn([$root . '/app/code/module1', $root . '/app/code/module2']); - $directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $directoryList = $this->getMock(\Magento\Framework\App\Filesystem\DirectoryList::class, [], [], '', false); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Setup\Module\I18n\Dictionary\Options\Resolver $resolver */ $resolver = $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Dictionary\Options\Resolver', + \Magento\Setup\Module\I18n\Dictionary\Options\Resolver::class, [ 'directory' => $directory, 'withContext' => $withContext, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/PhraseTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/PhraseTest.php index b04d02b5084b751b8f259ee170cdff7adfe3407f..39a852fb5e7fb63d31c858ad841ddfd0ca137b24 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/PhraseTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/PhraseTest.php @@ -17,7 +17,7 @@ class PhraseTest extends \PHPUnit_Framework_TestCase */ public function testPhraseCreation($constructArguments, $getter, $result) { - $reflectionClass = new \ReflectionClass('Magento\Setup\Module\I18n\Dictionary\Phrase'); + $reflectionClass = new \ReflectionClass(\Magento\Setup\Module\I18n\Dictionary\Phrase::class); $phrase = $reflectionClass->newInstanceArgs($constructArguments); $this->assertEquals($result, $phrase->{$getter}()); } @@ -58,7 +58,7 @@ class PhraseTest extends \PHPUnit_Framework_TestCase { $this->setExpectedException('DomainException', $message); - $reflectionClass = new \ReflectionClass('Magento\Setup\Module\I18n\Dictionary\Phrase'); + $reflectionClass = new \ReflectionClass(\Magento\Setup\Module\I18n\Dictionary\Phrase::class); $reflectionClass->newInstanceArgs($constructArguments); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Writer/Csv/StdoTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Writer/Csv/StdoTest.php index 1765ea37d0a77b35e861be42711b6d288098d55d..37fb24afe97a85eb78d398fc8111146b6c13d32f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Writer/Csv/StdoTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Writer/Csv/StdoTest.php @@ -21,7 +21,7 @@ class StdoTest extends \PHPUnit_Framework_TestCase { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Setup\Module\I18n\Dictionary\Writer\Csv $writer */ - $writer = $objectManagerHelper->getObject('Magento\Setup\Module\I18n\Dictionary\Writer\Csv\Stdo'); + $writer = $objectManagerHelper->getObject(\Magento\Setup\Module\I18n\Dictionary\Writer\Csv\Stdo::class); $this->assertAttributeEquals($this->_handler, '_fileHandler', $writer); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Writer/CsvTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Writer/CsvTest.php index dd8a2575799b94790ab5679c9904d9a06a8ceaf7..53c0355403c679fa0af427b4eb169bccfeb742a6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Writer/CsvTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Writer/CsvTest.php @@ -27,14 +27,14 @@ class CsvTest extends \PHPUnit_Framework_TestCase $this->_testFile = str_replace('\\', '/', realpath(dirname(__FILE__))) . '/_files/test.csv'; $this->_phraseFirstMock = $this->getMock( - 'Magento\Setup\Module\I18n\Dictionary\Phrase', + \Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false ); $this->_phraseSecondMock = $this->getMock( - 'Magento\Setup\Module\I18n\Dictionary\Phrase', + \Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', @@ -57,7 +57,7 @@ class CsvTest extends \PHPUnit_Framework_TestCase { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Dictionary\Writer\Csv', + \Magento\Setup\Module\I18n\Dictionary\Writer\Csv::class, ['outputFilename' => 'wrong/path'] ); } @@ -125,7 +125,7 @@ class CsvTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Setup\Module\I18n\Dictionary\Writer\Csv $writer */ $writer = $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Dictionary\Writer\Csv', + \Magento\Setup\Module\I18n\Dictionary\Writer\Csv::class, ['outputFilename' => $this->_testFile] ); $writer->write($this->_phraseFirstMock); @@ -166,7 +166,7 @@ EXPECTED; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \Magento\Setup\Module\I18n\Dictionary\Writer\Csv $writer */ $writer = $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Dictionary\Writer\Csv', + \Magento\Setup\Module\I18n\Dictionary\Writer\Csv::class, ['outputFilename' => $this->_testFile] ); $writer->write($this->_phraseFirstMock); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/DictionaryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/DictionaryTest.php index fc43163461ca2b7b6781866f12a44fc48cf3fc82..36975cc69c9becbae4b503e397c9ff4d3cef8e8e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/DictionaryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/DictionaryTest.php @@ -15,13 +15,13 @@ class DictionaryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_dictionary = $objectManagerHelper->getObject('Magento\Setup\Module\I18n\Dictionary'); + $this->_dictionary = $objectManagerHelper->getObject(\Magento\Setup\Module\I18n\Dictionary::class); } public function testPhraseCollecting() { - $phraseFirstMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseSecondMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phraseFirstMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseSecondMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $this->_dictionary->addPhrase($phraseFirstMock); $this->_dictionary->addPhrase($phraseSecondMock); @@ -31,11 +31,11 @@ class DictionaryTest extends \PHPUnit_Framework_TestCase public function testGetDuplicates() { - $phraseFirstMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phraseFirstMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $phraseFirstMock->expects($this->once())->method('getKey')->will($this->returnValue('key_1')); - $phraseSecondMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phraseSecondMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $phraseSecondMock->expects($this->once())->method('getKey')->will($this->returnValue('key_1')); - $phraseThirdMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phraseThirdMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $phraseThirdMock->expects($this->once())->method('getKey')->will($this->returnValue('key_3')); $this->_dictionary->addPhrase($phraseFirstMock); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/FactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/FactoryTest.php index 720ccfa08735bf6123c4127fbd23863165238994..48085cb0da7fd663396ac4f58f3081002b76cf18 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/FactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/FactoryTest.php @@ -15,7 +15,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->factory = $objectManagerHelper->getObject('Magento\Setup\Module\I18n\Factory'); + $this->factory = $objectManagerHelper->getObject(\Magento\Setup\Module\I18n\Factory::class); } /** @@ -38,19 +38,19 @@ class FactoryTest extends \PHPUnit_Framework_TestCase { return [ [ - 'Magento\Setup\Module\I18n\Dictionary\Writer\Csv', + \Magento\Setup\Module\I18n\Dictionary\Writer\Csv::class, TESTS_TEMP_DIR . '/filename.invalid_type', ], [ - 'Magento\Setup\Module\I18n\Dictionary\Writer\Csv', + \Magento\Setup\Module\I18n\Dictionary\Writer\Csv::class, TESTS_TEMP_DIR . '/filename' ], [ - 'Magento\Setup\Module\I18n\Dictionary\Writer\Csv', + \Magento\Setup\Module\I18n\Dictionary\Writer\Csv::class, TESTS_TEMP_DIR . '/filename.csv' ], [ - 'Magento\Setup\Module\I18n\Dictionary\Writer\Csv\Stdo', + \Magento\Setup\Module\I18n\Dictionary\Writer\Csv\Stdo::class, '' ], ]; diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/FilesCollectorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/FilesCollectorTest.php index a69044cdcf3b1e7a0c30f800adff970bb774b3d9..130e7d2461db8ad0fb91d410a4efb2abe9eaf853 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/FilesCollectorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/FilesCollectorTest.php @@ -22,7 +22,7 @@ class FilesCollectorTest extends \PHPUnit_Framework_TestCase $this->_testDir = str_replace('\\', '/', realpath(dirname(__FILE__))) . '/_files/files_collector/'; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_filesCollector = $objectManagerHelper->getObject('Magento\Setup\Module\I18n\FilesCollector'); + $this->_filesCollector = $objectManagerHelper->getObject(\Magento\Setup\Module\I18n\FilesCollector::class); } public function testGetFilesWithoutMask() diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Pack/GeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Pack/GeneratorTest.php index c4afa08f18c772b77b10a6e8531146c612437aff..0ec524c9ab25b87dd6a4e47483ffa02e4025a1e0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Pack/GeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Pack/GeneratorTest.php @@ -37,14 +37,14 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dictionaryLoaderMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Loader\FileInterface'); - $this->packWriterMock = $this->getMock('Magento\Setup\Module\I18n\Pack\WriterInterface'); - $this->factoryMock = $this->getMock('Magento\Setup\Module\I18n\Factory', [], [], '', false); - $this->dictionaryMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary', [], [], '', false); + $this->dictionaryLoaderMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Loader\FileInterface::class); + $this->packWriterMock = $this->getMock(\Magento\Setup\Module\I18n\Pack\WriterInterface::class); + $this->factoryMock = $this->getMock(\Magento\Setup\Module\I18n\Factory::class, [], [], '', false); + $this->dictionaryMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary::class, [], [], '', false); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_generator = $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Pack\Generator', + \Magento\Setup\Module\I18n\Pack\Generator::class, [ 'dictionaryLoader' => $this->dictionaryLoaderMock, 'packWriter' => $this->packWriterMock, @@ -59,9 +59,9 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $localeString = 'locale'; $mode = 'mode'; $allowDuplicates = true; - $localeMock = $this->getMock('Magento\Setup\Module\I18n\Locale', [], [], '', false); + $localeMock = $this->getMock(\Magento\Setup\Module\I18n\Locale::class, [], [], '', false); - $phrases = [$this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false)]; + $phrases = [$this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false)]; $this->dictionaryMock->expects($this->once()) ->method('getPhrases') ->will($this->returnValue([$phrases])); @@ -91,7 +91,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $localeString = 'locale'; $mode = 'mode'; $allowDuplicates = true; - $localeMock = $this->getMock('Magento\Setup\Module\I18n\Locale', [], [], '', false); + $localeMock = $this->getMock(\Magento\Setup\Module\I18n\Locale::class, [], [], '', false); $this->factoryMock->expects($this->once()) ->method('createLocale') @@ -114,15 +114,15 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $allowDuplicates = false; - $phraseFirstMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phraseFirstMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $phraseFirstMock->expects($this->once())->method('getPhrase')->will($this->returnValue('phrase1')); - $phraseSecondMock = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phraseSecondMock = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $phraseSecondMock->expects($this->once())->method('getPhrase')->will($this->returnValue('phrase2')); $this->dictionaryLoaderMock->expects($this->any()) ->method('load') ->will($this->returnValue($this->dictionaryMock)); - $phrases = [$this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false)]; + $phrases = [$this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false)]; $this->dictionaryMock->expects($this->once()) ->method('getPhrases') ->will($this->returnValue([$phrases])); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php index 7957577ac732fe3b674fa61e6f172e4720bfbd62..a9325196d1005aa360877e099489bc17d10275b7 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php @@ -15,7 +15,7 @@ class AbstractParserTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_parserMock = $this->getMockForAbstractClass( - 'Magento\Setup\Module\I18n\Parser\AbstractParser', + \Magento\Setup\Module\I18n\Parser\AbstractParser::class, [], '', false @@ -31,7 +31,10 @@ class AbstractParserTest extends \PHPUnit_Framework_TestCase { $this->setExpectedException('InvalidArgumentException', $message); - $this->_parserMock->addAdapter('php', $this->getMock('Magento\Setup\Module\I18n\Parser\AdapterInterface')); + $this->_parserMock->addAdapter( + 'php', + $this->getMock(\Magento\Setup\Module\I18n\Parser\AdapterInterface::class) + ); $this->_parserMock->parse($options); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/AbstractAdapterTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/AbstractAdapterTest.php index 02776c900ab5e6b271569ecab16be60232b5d7e7..0bad94e6e9a172c21c67d16147645eab1af5dcb0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/AbstractAdapterTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/AbstractAdapterTest.php @@ -20,7 +20,7 @@ class AbstractAdapterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_adapterMock = $this->getMockForAbstractClass( - 'Magento\Setup\Module\I18n\Parser\Adapter\AbstractAdapter', + \Magento\Setup\Module\I18n\Parser\Adapter\AbstractAdapter::class, [], '', false, @@ -29,7 +29,7 @@ class AbstractAdapterTest extends \PHPUnit_Framework_TestCase ['_parse'] ); $this->_adapterReflection = new \ReflectionMethod( - 'Magento\Setup\Module\I18n\Parser\Adapter\AbstractAdapter', + \Magento\Setup\Module\I18n\Parser\Adapter\AbstractAdapter::class, '_addPhrase' ); $this->_adapterReflection->setAccessible(true); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/HtmlTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/HtmlTest.php index 96b1a11f7e774656b21d19159e30afe4251e6781..841b4650cd09d7d2ed20b73c94e581d0c54d6227 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/HtmlTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/HtmlTest.php @@ -30,7 +30,7 @@ class HtmlTest extends \PHPUnit_Framework_TestCase $this->_testFile = str_replace('\\', '/', realpath(dirname(__FILE__))) . '/_files/email.html'; $this->_stringsCount = count(file($this->_testFile)); - $this->_adapter = (new ObjectManager($this))->getObject('Magento\Setup\Module\I18n\Parser\Adapter\Html'); + $this->_adapter = (new ObjectManager($this))->getObject(\Magento\Setup\Module\I18n\Parser\Adapter\Html::class); } public function testParse() diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/JsTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/JsTest.php index ce31d681006351a88398636f380ee4ab7e8bb304..87182185f6277ee1a7d4bcd00c3e3804f1588d14 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/JsTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/JsTest.php @@ -30,7 +30,7 @@ class JsTest extends \PHPUnit_Framework_TestCase $this->_testFile = str_replace('\\', '/', realpath(dirname(__FILE__))) . '/_files/file.js'; $this->_stringsCount = count(file($this->_testFile)); - $this->_adapter = (new ObjectManager($this))->getObject('Magento\Setup\Module\I18n\Parser\Adapter\Js'); + $this->_adapter = (new ObjectManager($this))->getObject(\Magento\Setup\Module\I18n\Parser\Adapter\Js::class); } public function testParse() diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/Tokenizer/PhraseCollectorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/Tokenizer/PhraseCollectorTest.php index c9718cbacd92743a7720a9a6df98241ce54f4548..724a42d26495a680262485f9f9614ffefdf0eafd 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/Tokenizer/PhraseCollectorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/Tokenizer/PhraseCollectorTest.php @@ -33,11 +33,11 @@ class PhraseCollectorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->tokenizerMock = $this->getMockBuilder('Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer') + $this->tokenizerMock = $this->getMockBuilder(\Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer::class) ->disableOriginalConstructor() ->getMock(); $this->phraseCollector = $this->objectManager->getObject( - 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector', + \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::class, [ 'tokenizer' => $this->tokenizerMock ] @@ -180,7 +180,7 @@ class PhraseCollectorTest extends \PHPUnit_Framework_TestCase $value, $line = null ) { - $token = $this->getMockBuilder('Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Token') + $token = $this->getMockBuilder(\Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Token::class) ->disableOriginalConstructor() ->getMock(); $token->expects($this->any()) @@ -216,7 +216,7 @@ class PhraseCollectorTest extends \PHPUnit_Framework_TestCase $phraseString = "'first part' . ' second part'"; $reflectionMethod = new \ReflectionMethod( - '\Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector', + \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::class, '_collectPhrase' ); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/Tokenizer/TokenTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/Tokenizer/TokenTest.php index bf6300a153ef728f309c65d9ce1dd53eeb048373..01e02b5fdf49ae6b01e8d4dcd278e973734f1b12 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/Tokenizer/TokenTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/Tokenizer/TokenTest.php @@ -110,7 +110,7 @@ class TokenTest extends \PHPUnit_Framework_TestCase { $line = 110; return $this->objectManager->getObject( - 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Token', + \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Token::class, [ 'name' => $name, 'value' => $value, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/TokenizerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/TokenizerTest.php index 70e8a9faa33fb67643f18de8303b204a5bd4b41f..5b454ec37dccd06f82b59d7de7d226a208c900e0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/TokenizerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/Php/TokenizerTest.php @@ -28,7 +28,7 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new ObjectManager($this); $this->tokenizer = $this->objectManager->getObject( - 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer' + \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer::class ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/PhpTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/PhpTest.php index 07269a4b1cfebf8cf5a7c50f6042d1e3790ce234..27729ae204b9c43d20bc794a84d35045d1a0ac55 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/PhpTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/PhpTest.php @@ -21,7 +21,7 @@ class PhpTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_phraseCollectorMock = $this->getMock( - 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector', + \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::class, [], [], '', @@ -30,7 +30,7 @@ class PhpTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_adapter = $objectManagerHelper->getObject( - 'Magento\Setup\Module\I18n\Parser\Adapter\Php', + \Magento\Setup\Module\I18n\Parser\Adapter\Php::class, ['phraseCollector' => $this->_phraseCollectorMock] ); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/XmlTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/XmlTest.php index de0f776419ecea7dcfc280540c658723c6cf166b..3ca9d6c37a1d0f04bf3533d65fc43f274c6397c8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/XmlTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/XmlTest.php @@ -22,7 +22,7 @@ class XmlTest extends \PHPUnit_Framework_TestCase $this->_testFile = str_replace('\\', '/', realpath(dirname(__FILE__))) . '/_files/default.xml'; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_adapter = $objectManagerHelper->getObject('Magento\Setup\Module\I18n\Parser\Adapter\Xml'); + $this->_adapter = $objectManagerHelper->getObject(\Magento\Setup\Module\I18n\Parser\Adapter\Xml::class); } public function testParse() diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/ParserTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/ParserTest.php index ff7d3525586a846c16d42af520af35f5bb154b5b..162264c39514ac24378e8fd0d28ce100b5db3a39 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/ParserTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/ParserTest.php @@ -30,8 +30,8 @@ class ParserTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesCollector = $this->getMock('Magento\Setup\Module\I18n\FilesCollector'); - $this->factory = $this->getMock('Magento\Setup\Module\I18n\Factory'); + $this->filesCollector = $this->getMock(\Magento\Setup\Module\I18n\FilesCollector::class); + $this->factory = $this->getMock(\Magento\Setup\Module\I18n\Factory::class); $this->parser = new Parser\Parser($this->filesCollector, $this->factory); } @@ -82,14 +82,14 @@ class ParserTest extends \PHPUnit_Framework_TestCase */ public function addPhraseDataProvider() { - $phraseMock1 = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseMock2 = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseMock3 = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseMock4 = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseMock5 = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseMock6 = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseMock7 = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); - $phraseMock8 = $this->getMock('Magento\Setup\Module\I18n\Dictionary\Phrase', [], [], '', false); + $phraseMock1 = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseMock2 = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseMock3 = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseMock4 = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseMock5 = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseMock6 = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseMock7 = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); + $phraseMock8 = $this->getMock(\Magento\Setup\Module\I18n\Dictionary\Phrase::class, [], [], '', false); $phraseMock1->expects($this->any())->method('getCompiledPhrase')->willReturn('php phrase111'); $phraseMock2->expects($this->any())->method('getCompiledPhrase')->willReturn('php phrase112'); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/ResourceFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/ResourceFactoryTest.php index a3f6fe3390b6097f0af0981298b75471b2dd01a5..baf7eb3d01a1a2ede384e75038445b66bb9a0961 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/ResourceFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/ResourceFactoryTest.php @@ -18,12 +18,15 @@ class ResourceFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $serviceLocatorMock = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface', ['get']); + $serviceLocatorMock = $this->getMockForAbstractClass( + \Zend\ServiceManager\ServiceLocatorInterface::class, + ['get'] + ); $connectionFactory = new ConnectionFactory($serviceLocatorMock); $serviceLocatorMock ->expects($this->once()) ->method('get') - ->with('Magento\Setup\Module\ConnectionFactory') + ->with(\Magento\Setup\Module\ConnectionFactory::class) ->will($this->returnValue($connectionFactory)); $this->resourceFactory = new ResourceFactory($serviceLocatorMock); } @@ -31,8 +34,8 @@ class ResourceFactoryTest extends \PHPUnit_Framework_TestCase public function testCreate() { $resource = $this->resourceFactory->create( - $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false) + $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false) ); - $this->assertInstanceOf('Magento\Framework\App\ResourceConnection', $resource); + $this->assertInstanceOf(\Magento\Framework\App\ResourceConnection::class, $resource); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/SetupFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/SetupFactoryTest.php index 1cf29b1510960d3d39adc7ca6e6a30b391dd7af9..5055a7fb26c75a96249f7f772fbcadc4994a6c27 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/SetupFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/SetupFactoryTest.php @@ -11,25 +11,35 @@ class SetupFactoryTest extends \PHPUnit_Framework_TestCase { public function testCreate() { - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); + $objectManager = $this->getMockForAbstractClass( + \Magento\Framework\ObjectManagerInterface::class, + [], + '', + false + ); $objectManager->expects($this->once()) ->method('get') - ->with('Magento\Framework\App\ResourceConnection') - ->willReturn($this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false)); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + ->with(\Magento\Framework\App\ResourceConnection::class) + ->willReturn($this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false)); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); $factory = new SetupFactory($objectManagerProvider); - $this->assertInstanceOf('Magento\Setup\Module\Setup', $factory->create()); + $this->assertInstanceOf(\Magento\Setup\Module\Setup::class, $factory->create()); } public function testCreateWithParam() { - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); + $objectManager = $this->getMockForAbstractClass( + \Magento\Framework\ObjectManagerInterface::class, + [], + '', + false + ); $objectManager->expects($this->never())->method('get'); - $resource = $this->getMock('Magento\Framework\App\ResourceConnection', [], [], '', false); - $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $objectManagerProvider = $this->getMock(\Magento\Setup\Model\ObjectManagerProvider::class, [], [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); $factory = new SetupFactory($objectManagerProvider); - $this->assertInstanceOf('Magento\Setup\Module\Setup', $factory->create($resource)); + $this->assertInstanceOf(\Magento\Setup\Module\Setup::class, $factory->create($resource)); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/SetupTest.php b/setup/src/Magento/Setup/Test/Unit/Module/SetupTest.php index 43c6fc0297ff08d09b0ed0c9cf01a0a35499a32a..231adb9ab695b16fb42aca2a8b18c2c7d7b05bff 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/SetupTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/SetupTest.php @@ -24,8 +24,8 @@ class SetupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $resourceModel = $this->getMock('\Magento\Framework\App\ResourceConnection', [], [], '', false); - $this->connection = $this->getMockForAbstractClass('\Magento\Framework\DB\Adapter\AdapterInterface'); + $resourceModel = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->connection = $this->getMockForAbstractClass(\Magento\Framework\DB\Adapter\AdapterInterface::class); $resourceModel->expects($this->any()) ->method('getConnection') ->with(self::CONNECTION_NAME) diff --git a/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php b/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php index 6f397a9c880a9a38d6c13187484532c1c55e0539..558533afe92429582cbfa79e5fcd691b200ecef8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php @@ -14,6 +14,8 @@ use Zend\Mvc\MvcEvent; /** * Tests Magento\Setup\Mvc\Bootstrap\InitParamListener + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InitParamListenerTest extends \PHPUnit_Framework_TestCase { @@ -46,22 +48,27 @@ class InitParamListenerTest extends \PHPUnit_Framework_TestCase public function testOnBootstrap() { /** @var \Zend\Mvc\MvcEvent|\PHPUnit_Framework_MockObject_MockObject $mvcEvent */ - $mvcEvent = $this->getMock('Zend\Mvc\MvcEvent'); - $mvcApplication = $this->getMockBuilder('Zend\Mvc\Application')->disableOriginalConstructor()->getMock(); + $mvcEvent = $this->getMock(\Zend\Mvc\MvcEvent::class); + $mvcApplication = $this->getMockBuilder(\Zend\Mvc\Application::class)->disableOriginalConstructor()->getMock(); $mvcEvent->expects($this->once())->method('getApplication')->willReturn($mvcApplication); - $serviceManager = $this->getMock('Zend\ServiceManager\ServiceManager'); + $serviceManager = $this->getMock(\Zend\ServiceManager\ServiceManager::class); $initParams[AppBootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::ROOT] = ['path' => '/test']; $serviceManager->expects($this->once())->method('get') ->willReturn($initParams); $serviceManager->expects($this->exactly(2))->method('setService') ->withConsecutive( - ['Magento\Framework\App\Filesystem\DirectoryList', - $this->isInstanceOf('Magento\Framework\App\Filesystem\DirectoryList')], - ['Magento\Framework\Filesystem', $this->isInstanceOf('Magento\Framework\Filesystem')] + [ + \Magento\Framework\App\Filesystem\DirectoryList::class, + $this->isInstanceOf(\Magento\Framework\App\Filesystem\DirectoryList::class) + ], + [ + \Magento\Framework\Filesystem::class, + $this->isInstanceOf(\Magento\Framework\Filesystem::class) + ] ); $mvcApplication->expects($this->any())->method('getServiceManager')->willReturn($serviceManager); - $eventManager = $this->getMockForAbstractClass('Zend\EventManager\EventManagerInterface'); + $eventManager = $this->getMockForAbstractClass(\Zend\EventManager\EventManagerInterface::class); $mvcApplication->expects($this->any())->method('getEventManager')->willReturn($eventManager); $eventManager->expects($this->any())->method('attach'); @@ -91,9 +98,9 @@ class InitParamListenerTest extends \PHPUnit_Framework_TestCase /** * @var \Zend\ServiceManager\ServiceLocatorInterface|\PHPUnit_Framework_MockObject_MockObject $serviceLocator */ - $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); - $mvcApplication = $this->getMockBuilder('Zend\Mvc\Application')->disableOriginalConstructor()->getMock(); - $request = $this->getMock('Zend\Stdlib\RequestInterface'); + $serviceLocator = $this->getMock(\Zend\ServiceManager\ServiceLocatorInterface::class); + $mvcApplication = $this->getMockBuilder(\Zend\Mvc\Application::class)->disableOriginalConstructor()->getMock(); + $request = $this->getMock(\Zend\Stdlib\RequestInterface::class); $mvcApplication->expects($this->any())->method('getRequest')->willReturn($request); $serviceLocator->expects($this->once())->method('get')->with('Application') ->willReturn($mvcApplication); @@ -117,9 +124,9 @@ class InitParamListenerTest extends \PHPUnit_Framework_TestCase /** * @var \Zend\ServiceManager\ServiceLocatorInterface|\PHPUnit_Framework_MockObject_MockObject $serviceLocator */ - $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); - $mvcApplication = $this->getMockBuilder('Zend\Mvc\Application')->disableOriginalConstructor()->getMock(); - $request = $this->getMockBuilder('Zend\Console\Request')->disableOriginalConstructor()->getMock(); + $serviceLocator = $this->getMock(\Zend\ServiceManager\ServiceLocatorInterface::class); + $mvcApplication = $this->getMockBuilder(\Zend\Mvc\Application::class)->disableOriginalConstructor()->getMock(); + $request = $this->getMockBuilder(\Zend\Console\Request::class)->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('getContent') ->willReturn( @@ -189,7 +196,7 @@ class InitParamListenerTest extends \PHPUnit_Framework_TestCase * @var \Magento\Framework\App\Filesystem\DirectoryList| * \PHPUnit_Framework_MockObject_MockObject $directoryList */ - $directoryList = $this->getMockBuilder('Magento\Framework\App\Filesystem\DirectoryList') + $directoryList = $this->getMockBuilder(\Magento\Framework\App\Filesystem\DirectoryList::class) ->disableOriginalConstructor()->getMock(); $directoryList->expects($this->any())->method('getPath')->willReturn($testPath); $filesystem = $this->listener->createFilesystem($directoryList); @@ -205,15 +212,16 @@ class InitParamListenerTest extends \PHPUnit_Framework_TestCase */ private function prepareEventManager() { - $this->callbackHandler = $this->getMockBuilder('Zend\Stdlib\CallbackHandler')->disableOriginalConstructor() + $this->callbackHandler = $this->getMockBuilder(\Zend\Stdlib\CallbackHandler::class) + ->disableOriginalConstructor() ->getMock(); /** @var \Zend\EventManager\EventManagerInterface|\PHPUnit_Framework_MockObject_MockObject $events */ - $eventManager = $this->getMock('Zend\EventManager\EventManagerInterface'); + $eventManager = $this->getMock(\Zend\EventManager\EventManagerInterface::class); - $sharedManager = $this->getMock('Zend\EventManager\SharedEventManager'); + $sharedManager = $this->getMock(\Zend\EventManager\SharedEventManager::class); $sharedManager->expects($this->once())->method('attach')->with( - 'Zend\Mvc\Application', + \Zend\Mvc\Application::class, MvcEvent::EVENT_BOOTSTRAP, [$this->listener, 'onBootstrap'] )->willReturn($this->callbackHandler); diff --git a/setup/src/Magento/Setup/Test/Unit/Validator/DbValidatorTest.php b/setup/src/Magento/Setup/Test/Unit/Validator/DbValidatorTest.php index 5b076e122a6e11057928132344baf8357f2d0a6f..c2353bd03d13b28e60fa8781dc6512da31846384 100644 --- a/setup/src/Magento/Setup/Test/Unit/Validator/DbValidatorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Validator/DbValidatorTest.php @@ -29,8 +29,8 @@ class DbValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->connectionFactory = $this->getMock('Magento\Setup\Module\ConnectionFactory', [], [], '', false); - $this->connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); + $this->connectionFactory = $this->getMock(\Magento\Setup\Module\ConnectionFactory::class, [], [], '', false); + $this->connection = $this->getMockForAbstractClass(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->connectionFactory->expects($this->any())->method('create')->willReturn($this->connection); $this->dbValidator = new DbValidator($this->connectionFactory); } @@ -42,7 +42,7 @@ class DbValidatorTest extends \PHPUnit_Framework_TestCase ->method('fetchOne') ->with('SELECT version()') ->willReturn('5.6.0-0ubuntu0.12.04.1'); - $pdo = $this->getMockForAbstractClass('Zend_Db_Statement_Interface', [], '', false); + $pdo = $this->getMockForAbstractClass(\Zend_Db_Statement_Interface::class, [], '', false); $this->connection ->expects($this->atLeastOnce()) ->method('query') @@ -92,7 +92,7 @@ class DbValidatorTest extends \PHPUnit_Framework_TestCase ->method('fetchOne') ->with('SELECT version()') ->willReturn('5.6.0-0ubuntu0.12.04.1'); - $pdo = $this->getMockForAbstractClass('Zend_Db_Statement_Interface', [], '', false); + $pdo = $this->getMockForAbstractClass(\Zend_Db_Statement_Interface::class, [], '', false); $this->connection ->expects($this->atLeastOnce()) ->method('query') @@ -122,7 +122,7 @@ class DbValidatorTest extends \PHPUnit_Framework_TestCase ->method('fetchOne') ->with('SELECT version()') ->willReturn('5.6.0-0ubuntu0.12.04.1'); - $pdo = $this->getMockForAbstractClass('Zend_Db_Statement_Interface', [], '', false); + $pdo = $this->getMockForAbstractClass(\Zend_Db_Statement_Interface::class, [], '', false); $this->connection ->expects($this->atLeastOnce()) ->method('query') @@ -167,7 +167,7 @@ class DbValidatorTest extends \PHPUnit_Framework_TestCase */ public function testCheckDatabaseConnectionFailed() { - $connectionFactory = $this->getMock('Magento\Setup\Module\ConnectionFactory', [], [], '', false); + $connectionFactory = $this->getMock(\Magento\Setup\Module\ConnectionFactory::class, [], [], '', false); $connectionFactory->expects($this->once())->method('create')->willReturn(false); $this->dbValidator = new DbValidator($connectionFactory); $this->dbValidator->checkDatabaseConnection('name', 'host', 'user', 'password');